Menu Close

Copy Files Listed in a Text File

Copy Files Listed in a Text File

Copy Files Listed in a Text File

Some times there are requirement to copy selected file from one folder (which contains many files) to another folder. for the same there is XCOPY command and FOR Loop command in batch file. Steps for copying files from one folder to another folder.

1. create one txt file which contains the files name in separate line with extension like; a.jpg, b.jpg, a.txt etc (names are from the folders where we have to copy the files)

2. make a batch file (.bat) and write this command in that

for /f “delims=” %%i in (filelist.txt) do echo D|xcopy “d:\pic\%%i” “d:\newpic\” /i /z /y

save the file on same location where .txt file saved.

in the above command pic is the folder where all the files exists and newpicis the location where we have to copy the selected files from txt file.

3. Now run the batch file, and all your selected file will now copy to newpic.