Cmd Batch file Copy Command Line - not working

I created the following batch command line file to copy a pdf and save it with a new name under a new folder.  Its supposed to do this for several times using the same file, but its not working.  What am I doing wrong?

Using Windows XP.
Saved as a .bat file
the ".att" at the end of the destination folder name is correct, it needed as part of our system to automatically identify and attach documents from each of these folders to emails that we send.



copy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_24880.att\First Financial Trust & Asset Management W9 - 24880.pdf"

copy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_21739.att\First Financial Trust & Asset Management W9 - 21739.pdf"

copy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_28535.att\First Financial Trust & Asset Management W9 - 28535.pdf"

etc....
IO_DorkAsked:
Who is Participating?
 
Christopher McKayMicrosoft Network AdministratorCommented:
You may want to add a "/y" to suppress prompting for the copy command, but I would recommend you try using xcopy, rather than copy.

xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_24880.att\First Financial Trust & Asset Management W9 - 24880.pdf" /y

xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_21739.att\First Financial Trust & Asset Management W9 - 21739.pdf" /y

xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_28535.att\First Financial Trust & Asset Management W9 - 28535.pdf" /y


Hope this helps!

:o)

Bartender_1
0
 
g3nu1n3Commented:
Are you getting an error message? Clarify what you mean by, "it is not working".
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
IO_DorkAuthor Commented:
it was doing nothing but Bartender_1's suggestion to use xcopy worked.

BTW - how do I handle it when the CMD prompts me to specify whether target is a file or directory?  I want it to always choose file or "f".
0
 
Christopher McKayMicrosoft Network AdministratorCommented:
If you want to suppress the prompt for file or directory, try this:


echo f | xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_24880.att\First Financial Trust & Asset Management W9 - 24880.pdf" /y

echo f | xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_21739.att\First Financial Trust & Asset Management W9 - 21739.pdf" /y

echo f | xcopy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTAM\inv_28535.att\First Financial Trust & Asset Management W9 - 28535.pdf" /y


Hope this helps!

:o)

Bartender_1
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The better method IMHO is to create the folder first, and then copy the file into that folder - and most important, use a FOR loop, that reduces the risk of typos and other errors:
@echo off
pushd .
for %%N in (24880 21739 28535) do (
   md C:\Documents and Settings\borr\Desktop\FFTAM\inv_%%N.att 2> nul
   cd C:\Documents and Settings\borr\Desktop\FFTAM\inv_%%N.att
   copy "C:\Documents and Settings\borr\Desktop\First Financial Trust  Asset Mgmt Abilene W9.pdf" "First Financial Trust  Asset Mgmt Abilene W9 - %%N.pdf"
)
popd

Open in new window

That still can be improved further, of course (like using vars for the repetitive parts).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.