Copy Files from Text List with spaces

Solved/Closed
Hercules - Feb 26, 2009 at 07:33 AM
 the SASS Man - Sep 9, 2010 at 07:48 PM
Hello,

I am trying to create a batch file to copy files from a list of locations in a .txt file to a new location.

The code below gives me an error, because the files have spaces in the names.

@echo off
echo -- > C:\TestingTMP.txt
xcopy /y C:\Testing.m3u C:\TestingTMP.txt
find "H:\Music" C:\TestingTMP.txt >> C:\Testing.txt
for /f %%a in (C:\Testing.txt) do (
xcopy /y %%a H:\Music\Testing
)

"Testing.txt":
H:\Music\Kutless\Kutless - Sea Of Faces.mp3
H:\Music\Tree 63\The Life And Times Of Absolute - Tree 63 - How Did I Sleep.mp3
etc.

Using a third party program (because all the forums indicate this is what it will take to do text find and replace), I have changed the list generated in "Testing.txt" and put inverted comma's around the files with spaces.

H:\"Music"\"Kutless"\"Kutless - Sea Of Faces".mp3
H:\"Music"\"Tree 63"\"The Life And Times Of Absolute - Tree 63 - How Did I Sleep".mp3
etc.

Now the code
for /f %%a in (C:\Testing.txt) do (
xcopy /y %%a H:\Music\Testing
gives me a "Parse Error"! And it still only looks at the title before the first space!
eg.
c:\>(xcopy /y H:\"Music"\"Kutless"\"Kutless - Sea H:\Music\Testing
Parse Error

Can anyone please shed some light on this supposed to be simple function and how to solve the problem?

4 responses

athenazob Posts 5 Registration date Tuesday September 16, 2008 Status Member Last seen February 27, 2009 8
Feb 27, 2009 at 01:41 AM
hi,
in fact you should use your original list and modify the "For /F" statement as written downwards:

for /F "delims=" %%a in (C:\Testing.txt) do (
xcopy /Y "%%a" H:\Music\Testing
)


hope it helps you.
8