Hi,
I am new to this forum and i am terrible in using batch files
I have some XML files for e.g.
1079.xml
35781.xml
75022.xml
10000.xml
here i need to move xml files which has the file names greater or equal to 35781 to a particular folder namely "less" in the same directory.
Please help me in this
Regards
Prashob
move files as per their filenames
Moderator: DosItHelp
prashob12,
This should work:
Open a command prompt and change to the directory where the XML files are. Then execute the following command:
DOS IT HELP?
This should work:
Open a command prompt and change to the directory where the XML files are. Then execute the following command:
Code: Select all
for %A in (*.xml) do @if %~nA GEQ 35781 move %A less
DOS IT HELP?
Sure:
uses the %A variable to loop through all files that match the "*.xml" file pattern and calls "command %A" for each file that matches the, whereas "%A" will be substituted with the matching file.
the "@" sign prevents the "if" command (or any other command) to be echoed back to the console.
"%~nA" is like "%A" except it resolves to the filename only, without extension or path - this is your number.
"if" is the condition command used to compare if the filename is Greater or EQual the number. "command %A" is only be executed when the condition is true.
Help for "FOR" command here: http://www.dostips.com/DosCommandIndex.htm#FOR
or on command line run: FOR /?
Help for "IF" command here: http://www.dostips.com/DosCommandIndex.htm#IF
or on command line run: IF /?
Let me know what is most confusion so I can improve the site.
for %A in (*.xml) do command %A
uses the %A variable to loop through all files that match the "*.xml" file pattern and calls "command %A" for each file that matches the, whereas "%A" will be substituted with the matching file.
@if %~nA GEQ 35781 command %A
the "@" sign prevents the "if" command (or any other command) to be echoed back to the console.
"%~nA" is like "%A" except it resolves to the filename only, without extension or path - this is your number.
"if" is the condition command used to compare if the filename is Greater or EQual the number. "command %A" is only be executed when the condition is true.
Help for "FOR" command here: http://www.dostips.com/DosCommandIndex.htm#FOR
or on command line run: FOR /?
Help for "IF" command here: http://www.dostips.com/DosCommandIndex.htm#IF
or on command line run: IF /?
Let me know what is most confusion so I can improve the site.