-2

I've been copying favorite songs for "THE MOST AWESOME CAR CD EVER" into a txt file. All the files are exact paths to the music. Now i want to parse the txt and copy what it finds into a folder... i`m not that fluent in batch so maybe you could help me out

Thanks

1 Answers1

2
@echo off
setlocal
for /f "usebackqdelims=" %%i in ("yourtextfilename.txt") do (
   ECHO XCOPY "%%i" "c:\yourdestfolder\"
)

for each line in the filename, where the filename is in double-quotes (usebackq) assign each line of the file to %%i in turn and XCOPY that file to c:\yourdestfolder\

The PROPOSED XCOPY will be echoed to the screen. This is deliberate to allow you to make sure that is what you want to do. To EXECUTE the XCOPY simply delete the ECHO keyword before it. If the "1 files copied" response irritates you, add >nul after "c:\yourdestfolder\" if you want to suppress the message.

"c:\yourdestfolder\" will be CREATED by XCOPY if it does not already exist. XCOPY will ask whether you want to overwrite existing files if there is already a file with the same name in "c:\yourdestfolder\" - which is why you may NOT want to suppress the messages.

Magoo
  • 77,302
  • 8
  • 62
  • 84