Batch - Copy Files using .txt List

February 26, 2009 at 05:49:55
Specs: Windows Vista
Hi,

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?


See More: Batch - Copy Files using .txt List

Report •


#1
February 26, 2009 at 07:21:37
Use your original list and modify the For /F statement as below

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


Report •

#2
February 26, 2009 at 21:43:37
That works beautifully, thanx!!

Report •

Related Solutions


Ask Question