| 1. |
Solve : Help needed in copying files using batch script? |
|
Answer» Hi Guys.... for /f "[emailprotected]" %%a in (textfile) do move /y %%a d:\What is that supposed to do, exactly? reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive if you are running it from the command line and not in a batch file it should be for /f "[emailprotected]" %a in (textfile) do move /y %a d:\OK. But why not use "delims=" which is the standard way of grabbing the whole line? Possible relevance: what delim to use to to read text file line by line Quote Not really, as "tokens=*" and "delims=" produce NEARLY the same result. As with "tokens=*" the delims are still active, they remove leading spaces and TABs from each line – jeb Jul 22 '11 at 11:29Quote from: erobby on November 15, 2015, 10:22:46 AM reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive As noted in posts above "delims=" is USEFUL - and if there are spaces, then won't your code break if the loop variable is unquoted?Using ROBOCOPY is probably the best solution, as it's able to create the direcory structure at the DESTINATION if it doesn't already exist. COPY and MOVE (on my system, Win8.1/64) simply error out with "The system cannot find the path specified." if the destination folders do not already exist. Also, the issue of using FOR and "[emailprotected]" has several problems as well, including things like handling spaces (easily fixed, though), and what happens if one of the source files has an @ character in the name? Of course, there's work-arounds/solutions to these problems.. But they should be AWARE in the first place, not just blindly use a FOR construct that seems to work "most of the time.." |
|