Windows batch command for file copy












0















Currently I am working with an old vbs script. In that I found that it calls an another .bat file.



WshShell.run "abc.bat " + logfilename + " " + exlogfilename ,3, True    


The abc.bat file contains below code.



@echo off
FOR /F "skip=1 delims=*" %%a IN ('dir /O-D /B \server1xyz*.log') DO move \server1xyz%%a D:folder1


Could anyone please explain what these two lines will exactly do. I've basic idea but confused with the parameters.
Powershell alternatives are also welcome.










share|improve this question

























  • It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

    – Compo
    Nov 13 '18 at 11:18
















0















Currently I am working with an old vbs script. In that I found that it calls an another .bat file.



WshShell.run "abc.bat " + logfilename + " " + exlogfilename ,3, True    


The abc.bat file contains below code.



@echo off
FOR /F "skip=1 delims=*" %%a IN ('dir /O-D /B \server1xyz*.log') DO move \server1xyz%%a D:folder1


Could anyone please explain what these two lines will exactly do. I've basic idea but confused with the parameters.
Powershell alternatives are also welcome.










share|improve this question

























  • It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

    – Compo
    Nov 13 '18 at 11:18














0












0








0








Currently I am working with an old vbs script. In that I found that it calls an another .bat file.



WshShell.run "abc.bat " + logfilename + " " + exlogfilename ,3, True    


The abc.bat file contains below code.



@echo off
FOR /F "skip=1 delims=*" %%a IN ('dir /O-D /B \server1xyz*.log') DO move \server1xyz%%a D:folder1


Could anyone please explain what these two lines will exactly do. I've basic idea but confused with the parameters.
Powershell alternatives are also welcome.










share|improve this question
















Currently I am working with an old vbs script. In that I found that it calls an another .bat file.



WshShell.run "abc.bat " + logfilename + " " + exlogfilename ,3, True    


The abc.bat file contains below code.



@echo off
FOR /F "skip=1 delims=*" %%a IN ('dir /O-D /B \server1xyz*.log') DO move \server1xyz%%a D:folder1


Could anyone please explain what these two lines will exactly do. I've basic idea but confused with the parameters.
Powershell alternatives are also welcome.







windows batch-file vbscript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 8:38









a_horse_with_no_name

293k46447541




293k46447541










asked Nov 13 '18 at 8:26









user10644895user10644895

42




42













  • It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

    – Compo
    Nov 13 '18 at 11:18



















  • It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

    – Compo
    Nov 13 '18 at 11:18

















It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

– Compo
Nov 13 '18 at 11:18





It appears to be moving all log files, except for the most recent, from the xyz directory to `D:folder1.

– Compo
Nov 13 '18 at 11:18












1 Answer
1






active

oldest

votes


















0














I believe it moves (not copies) every logfile (extension *.log) from the server \server1, subdirectory \server1xyz to a local directory D:Folder1.



The directives /O-D and /B are just there to make the script work (ordering the results and showing only filenames). They don't modify the behaviour of the batchfile.






share|improve this answer





















  • 1





    "The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

    – Gerhard Barnard
    Nov 13 '18 at 8:55













  • @GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

    – Dominique
    Nov 13 '18 at 9:09











  • Maybe just add what the switches does then

    – Gerhard Barnard
    Nov 13 '18 at 9:10











  • Could you please tell me what these parameters means /F "skip=1 delims=*"

    – user10644895
    Nov 13 '18 at 9:34













  • @user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

    – Gerhard Barnard
    Nov 13 '18 at 10:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276729%2fwindows-batch-command-for-file-copy%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I believe it moves (not copies) every logfile (extension *.log) from the server \server1, subdirectory \server1xyz to a local directory D:Folder1.



The directives /O-D and /B are just there to make the script work (ordering the results and showing only filenames). They don't modify the behaviour of the batchfile.






share|improve this answer





















  • 1





    "The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

    – Gerhard Barnard
    Nov 13 '18 at 8:55













  • @GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

    – Dominique
    Nov 13 '18 at 9:09











  • Maybe just add what the switches does then

    – Gerhard Barnard
    Nov 13 '18 at 9:10











  • Could you please tell me what these parameters means /F "skip=1 delims=*"

    – user10644895
    Nov 13 '18 at 9:34













  • @user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

    – Gerhard Barnard
    Nov 13 '18 at 10:06
















0














I believe it moves (not copies) every logfile (extension *.log) from the server \server1, subdirectory \server1xyz to a local directory D:Folder1.



The directives /O-D and /B are just there to make the script work (ordering the results and showing only filenames). They don't modify the behaviour of the batchfile.






share|improve this answer





















  • 1





    "The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

    – Gerhard Barnard
    Nov 13 '18 at 8:55













  • @GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

    – Dominique
    Nov 13 '18 at 9:09











  • Maybe just add what the switches does then

    – Gerhard Barnard
    Nov 13 '18 at 9:10











  • Could you please tell me what these parameters means /F "skip=1 delims=*"

    – user10644895
    Nov 13 '18 at 9:34













  • @user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

    – Gerhard Barnard
    Nov 13 '18 at 10:06














0












0








0







I believe it moves (not copies) every logfile (extension *.log) from the server \server1, subdirectory \server1xyz to a local directory D:Folder1.



The directives /O-D and /B are just there to make the script work (ordering the results and showing only filenames). They don't modify the behaviour of the batchfile.






share|improve this answer















I believe it moves (not copies) every logfile (extension *.log) from the server \server1, subdirectory \server1xyz to a local directory D:Folder1.



The directives /O-D and /B are just there to make the script work (ordering the results and showing only filenames). They don't modify the behaviour of the batchfile.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 9:23

























answered Nov 13 '18 at 8:38









DominiqueDominique

1,83741539




1,83741539








  • 1





    "The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

    – Gerhard Barnard
    Nov 13 '18 at 8:55













  • @GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

    – Dominique
    Nov 13 '18 at 9:09











  • Maybe just add what the switches does then

    – Gerhard Barnard
    Nov 13 '18 at 9:10











  • Could you please tell me what these parameters means /F "skip=1 delims=*"

    – user10644895
    Nov 13 '18 at 9:34













  • @user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

    – Gerhard Barnard
    Nov 13 '18 at 10:06














  • 1





    "The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

    – Gerhard Barnard
    Nov 13 '18 at 8:55













  • @GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

    – Dominique
    Nov 13 '18 at 9:09











  • Maybe just add what the switches does then

    – Gerhard Barnard
    Nov 13 '18 at 9:10











  • Could you please tell me what these parameters means /F "skip=1 delims=*"

    – user10644895
    Nov 13 '18 at 9:34













  • @user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

    – Gerhard Barnard
    Nov 13 '18 at 10:06








1




1





"The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

– Gerhard Barnard
Nov 13 '18 at 8:55







"The directives /O-D and /B are just there to make the script work. They don't modify the behaviour of the batchfile." I am sorry, but that is completely wrong. /O is a sort order switch using -D which is sorting by date in reverse order. /B is a bare format switch. All of these switches modify the behaviour of the outcome of the batch script.

– Gerhard Barnard
Nov 13 '18 at 8:55















@GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

– Dominique
Nov 13 '18 at 9:09





@GerhardBarnard: indeed, I just meant that those switches don't cause the dir command to start searching subdirectories or things like that.

– Dominique
Nov 13 '18 at 9:09













Maybe just add what the switches does then

– Gerhard Barnard
Nov 13 '18 at 9:10





Maybe just add what the switches does then

– Gerhard Barnard
Nov 13 '18 at 9:10













Could you please tell me what these parameters means /F "skip=1 delims=*"

– user10644895
Nov 13 '18 at 9:34







Could you please tell me what these parameters means /F "skip=1 delims=*"

– user10644895
Nov 13 '18 at 9:34















@user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

– Gerhard Barnard
Nov 13 '18 at 10:06





@user10644895 open cmd.exe and type for /? it will give you everything you need to know about the for loop.

– Gerhard Barnard
Nov 13 '18 at 10:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276729%2fwindows-batch-command-for-file-copy%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud