How to batch copy a list of folders and its file contents from a text file into a new folder in windows

150 Views Asked by At

I have a folder with approximately 7000 subfolders. I am interested in copying 1500 of those subfolders and their file contents into a new folder.

The closest I have got is copying the subfolders file contents into a new Target folder. However, the file contents are not copied over within their resepective subfolder making the batch copy useless to me.

Here is what I have tried.


CD E:\Source_Folder

FOR /F "delims=" %%N in (List.txt) do COPY "%%N" "Target_Folder"

I have tried XCOPY, ROBOCOPY, as well and all give me the same output of individual files in my target folder. I am looking for the subfolders with their contents to be copied into my new target folder.

Any help would be much appreciated. Thanks!

1

There are 1 best solutions below

1
treebee On

Just a try: rsync in linux does have the option to take the file-list to be synced from a file. Maybe robocopy (which is the windows-pendant) has the same capability, then you need one robocopy x y z only. -edit: robocopy can'r read from a file, but if you search for 'robocopy reading from list' you get a lot of short scripts.