Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
Does cd folder copy *.txt newfolder work? –  Hennes Nov 5 '12 at 14:08
No, I'm not trying to copy every *.txt file, but I have a txt file which contains a list of desired files I want to copy. –  drum Nov 5 '12 at 14:13
You have similar answer and question [here][1] [1]: stackoverflow.com/questions/1224880/… –  mno2014 Nov 5 '12 at 14:43

1 Answer 1

up vote 2 down vote accepted

Iterate over the text file:

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

Copy the files:

copy "%%L" new_folder


for /f "delims=" %%L in (foo.txt) do copy "%%L" new_folder
share|improve this answer
Which should be my current folder when running this? –  drum Nov 5 '12 at 14:11
So for your script I need to be in the folder with all of the files. I noticed that the batch doesn't work unless I have everything in one single line. –  drum Nov 5 '12 at 14:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.