For Loop Using Text File As Input Problem

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dc1743
Posts: 2
Joined: 21 Jun 2010 04:32

For Loop Using Text File As Input Problem

#1 Post by dc1743 » 21 Jun 2010 04:35

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?

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: For Loop Using Text File As Input Problem

#2 Post by avery_larry » 21 Jun 2010 10:22

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 . . .

dc1743
Posts: 2
Joined: 21 Jun 2010 04:32

Re: For Loop Using Text File As Input Problem

#3 Post by dc1743 » 21 Jun 2010 23:04

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.

Post Reply