Page 1 of 1

For Loop Using Text File As Input Problem

Posted: 21 Jun 2010 04:35
by dc1743
I have a text file (SingleFilesList.txt) listing a
series of files including their path in the form

T:\A test directory\3\E\0\123456789.jpg
T:\A test directory\3\F\5\123456790.jpg
T:\A test directory\F\1\2\123456789.jpg

I would like to copy all the files listed into one
folder. I have used at the DOS command
prompt:

For /F "tokens=*" %K in (SingleFilesList.txt)
Do Copy "%K" V:\Test\

No errors are generated but files are not
copied to V:\Test. Please can anyone
suggest where I am going wrong?

Re: For Loop Using Text File As Input Problem

Posted: 21 Jun 2010 10:22
by avery_larry
Is that all on one line?

for /f "usebackq delims=" %a in ("c:\path to file\singlefileslist.txt") do copy "%a" v:\test


If there is no ouput on the screen, my first guess is that it can't find singlefileslist.txt . . .

Re: For Loop Using Text File As Input Problem

Posted: 21 Jun 2010 23:04
by dc1743
Thank you for your reply. At first the command didn't work but your comment about SingleFilesList.txt caused me to look at the file in a hex editor. For some reason a single FF character preceded the first T. Deleting this character solved it.

Your command
for /f "usebackq delims=" %a in ("c:\path to file\singlefileslist.txt") do copy "%a" v:\test

worked as did
For /F "tokens=*" %K in (SingleFilesList.txt) Do (Copy "%K" V:\Test\)

which someone had suggested on another forum.

Thanks again for your help.