Windows – How to copy files according to file list using batch script

cmd.exewindows

I have a folder with a multitude of files, and I have a list (txt) of specific files which I want to copy from this folder.

It will go something like this:
For each filename:
cp (filename in folder) to (filename in new_folder)

How can I do the above using batch script?

Best Answer

Iterate over the text file:

for /f "delims=" %%L in (foo.txt) do

Copy the files:

copy "%%L" new_folder

Done:

for /f "delims=" %%L in (foo.txt) do copy "%%L" new_folder
Related Question