-3

I want to copy many text files from one folder to another. The file names are contained in another text file. So the commands should be able to read in the file names and do the copy things. I can do this with R but it's very slow. I wonder if it's possible to do this with the command line? (I can copy single file with the command line, but don't know how to copy many with for or while loop or something.) Thanks in advance.

1 Answers1

0

I found this question helpful: How do you loop through each line in a text file using a windows batch file?

This is what you need to just paste into the command line. If you want to save it in a bash file you need to use %% instead of % for variables.

for /F "tokens=*" %a in (myfile.txt) do copy "%a" "new folder\%a"

This simply loops through the file, and for each line does a copy of it to the new folder. The quotes are important in case of spaces in the filenames.

Community
  • 1
  • 1
Beth Crane
  • 625
  • 3
  • 8