Computing.Net > Forums > Programming > Batch - Copy Files using .txt List

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch - Copy Files using .txt List

Reply to Message Icon

Name: Jaco
Date: February 26, 2009 at 05:49:55 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: February 26, 2009 at 07:21:37 Pacific
Reply:

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
)


0

Response Number 2
Name: Jaco
Date: February 26, 2009 at 21:43:37 Pacific
Reply:

That works beautifully, thanx!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch - Copy Files using .txt List

Copying Files Using Text List www.computing.net/answers/programming/copying-files-using-text-list/18668.html

Batch copy files on txt file incl. subdir. www.computing.net/answers/programming/batch-copy-files-on-txt-file-incl-subdir/20053.html

batch copy file on Ping Errorlevel= www.computing.net/answers/programming/batch-copy-file-on-ping-errorlevel/18016.html