Search : in
By :

Copy Files from Text List with spaces

Last answer on Feb 27, 2009 6:41:41 am GMT Hercules, on Feb 26, 2009 12:33:31 pm GMT 
 Report this message to moderators

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?

Configuration: Windows Vista
Internet Explorer 7.0

Best answers for « Copy Files from Text List with spaces » in :
Unable to delete file: Argument list too long Show Unable to delete file: Argument list too long Solutions Xargs Command find loop for (bash) Program Perl When trying to delete a file , you receive the following error message : bash: /bin/rm: Argument list too long This is...
[MS-Dos]List the contents of a directory in a file Show[MS-Dos]List the contents of a directory in a file Intro Explanation Intro It may be convenient to make the listing of one or more directories in a file, to make a catalog of files. Under MS-DOS (or Windows by opening a...
Writing in batch in text file ShowWriting in batch in text file To write in a file text, you just have to use a redirect: echo text > output_file.txt To write in an existing file: echo " Write at the end of the file ">> output_file.txt
Moving or copying a file with your right mouse button ShowMoving or copying a file with your right mouse button Command for right mouse button Create a file in the registry Set up of the file in the registry Command for right mouse button To move or copy your document and file to another...
Download Shadow Copy ShowNormally, the administrators of files as the explorer Windows do not allow the copy of opened or blocked files. For instance if you are treating a document Word, you have no possibility of copying it in another file during its edition. Shadow Copy is...
Download Teracopy ShowTeraCopy is a compact program designed to copy and move files at the maximum possible speed.It is free for Home Users. Features: Copy files faster. TeraCopy uses dynamically adjusted buffers to reduce seek times. Asynchronous copy speeds up...
Download Flextk Ultimate ShowFlexTk Ultimate is a tool to manage your files and folders. It can help you to classify your folders, categorize them, find duplicate files, free up space, copy/move or synchronize a large number of files and much more. You can also digitize...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
Using FTP commands ShowThe FTP protocol FTP (File Transfer Protocol) is a protocol — meaning a standard language that lets two machines communicate — used so that computers of different types (or with different operating systems) can transfer files over a...
MS DOS Files and directories ShowFiles in MS DOS In a computers data is stored in files. When you run a program, MS-DOS processes the data stored in the file and passes it to the system. In MS-DOS a file can be any size, however the file name is more restricted, it can only have...

1

 athenazob, on Feb 27, 2009 6:41:41 am GMT
  • +2

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.

Reply to athenazob