I have a directory with thousands of files named as number.jpg (ex: 100152.jpg
, 100153.jpg
). I don't want to copy everything in this directory — only the files with the exact name as the names in a text file list that I have created.
There are about 36k names in this shorter list — I want to copy all the files in the large directory that have the same names as the ones in the list into a separate folder.
How would I be able to do this without going one by one on a Windows system?
Best Answer
You can use a FOR /F and reference the full path of the file list as show below.
This will essentially read each line of the file list you point to, line by line, and iterate the returned value (content of each line) to the XCOPY command to process accordingly.
Command Line Syntax
Batch Script Syntax
Further Resources