Link to home
Start Free TrialLog in
Avatar of IO_Dork
IO_DorkFlag for United States of America

asked on

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....
Avatar of chubby_informer
chubby_informer
Flag of Trinidad and Tobago image

ASKER CERTIFIED SOLUTION
Avatar of Bartender_1
Bartender_1
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you getting an error message? Clarify what you mean by, "it is not working".
Avatar of IO_Dork

ASKER

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".
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
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).