IO_Dork
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\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2488 0.att\Firs t Financial Trust & Asset Management W9 - 24880.pdf"
copy "C:\Documents and Settings\borr\Desktop\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2173 9.att\Firs t Financial Trust & Asset Management W9 - 21739.pdf"
copy "C:\Documents and Settings\borr\Desktop\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2853 5.att\Firs t Financial Trust & Asset Management W9 - 28535.pdf"
etc....
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\Firs
copy "C:\Documents and Settings\borr\Desktop\Firs
copy "C:\Documents and Settings\borr\Desktop\Firs
etc....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you getting an error message? Clarify what you mean by, "it is not working".
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".
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\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2488 0.att\Firs t Financial Trust & Asset Management W9 - 24880.pdf" /y
echo f | xcopy "C:\Documents and Settings\borr\Desktop\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2173 9.att\Firs t Financial Trust & Asset Management W9 - 21739.pdf" /y
echo f | xcopy "C:\Documents and Settings\borr\Desktop\Firs t Financial Trust Asset Mgmt Abilene W9.pdf" "C:\Documents and Settings\borr\Desktop\FFTA M\inv_2853 5.att\Firs t Financial Trust & Asset Management W9 - 28535.pdf" /y
Hope this helps!
:o)
Bartender_1
echo f | xcopy "C:\Documents and Settings\borr\Desktop\Firs
echo f | xcopy "C:\Documents and Settings\borr\Desktop\Firs
echo f | xcopy "C:\Documents and Settings\borr\Desktop\Firs
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
That still can be improved further, of course (like using vars for the repetitive parts).
http://answers.yahoo.com/question/index?qid=20071021190652AAPIY4y
http://www.ehow.com/how_6196447_copy-files-using-command-prompt.html
have a look here