?
Solved

Cmd Batch file Copy Command Line - not working

Posted on 2012-09-13
6
Medium Priority
?
1,489 Views
Last Modified: 2012-09-13
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....
0
Comment
Question by:IO_Dork
6 Comments
 
LVL 22

Accepted Solution

by:
Christopher McKay earned 2000 total points
ID: 38395648
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
 
LVL 6

Expert Comment

by:g3nu1n3
ID: 38395657
Are you getting an error message? Clarify what you mean by, "it is not working".
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:IO_Dork
ID: 38395771
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
 
LVL 22

Expert Comment

by:Christopher McKay
ID: 38395836
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
 
LVL 71

Expert Comment

by:Qlemo
ID: 38395924
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question