Batch code to find a list of filenames in a dir. and copy

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Superdonk
Posts: 2
Joined: 25 Nov 2013 06:27

Batch code to find a list of filenames in a dir. and copy

#1 Post by Superdonk » 14 Jan 2014 06:31

hi guys

I'm not even sure whether this is possible, but...

I have a list of filenames (abcd.pdf, 1234.pdf etc) that i want to search in a directory, which has sub directories to find each of the filenames and copy them to a new folder.

Can you help?!?

TVM

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch code to find a list of filenames in a dir. and cop

#2 Post by penpen » 14 Jan 2014 07:49

Maybe this batch may help you:

Code: Select all

for /F "tokens=* delims=" %%a in ('dir abcd.pdf 1234.pdf /A-D /B /S 2^>nul') do echo copy "%%~a" newTargetFolder
Remove the echo, if this is what you wanted to do.

penpen

Post Reply