Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple batch file Win2000 problem w/copy command

Status
Not open for further replies.

pbbriggs

MIS
Jun 24, 2003
68
US
I apologize for this novice question, but I am brand new to batch files. I wrote a simple "copy" batch file to copy a file to another directory. It then deletes an existing file in the destination directory, and renames the newly-copied file (giving it the name of the file which was just deleted). Essentially, I am setting up some personnel to run a backup of a database.

The problem is, this batch file works fine on PCs running Windows 98, but will not run on PCs running Windows 2000. This is the batch file:

copy G:\Source\File.mdb G:\Destination
del G:\Destination\Backup.mdb
rename G:\Destination\File.mdb Backup.mdb

It is doing the "del" step but not the copy step. Did the copy command change somehow in Windows 2000? Also, what's strange is I don't get an error message. It appears to run, but then when I check for the copied file it is not present.

Thank you very much, and sorry for being such an amateur!

 
Since you're new, an important tip, when a script isn't working, open a command prompt, type each of the commands one at a time until it fails. When it does fail, you'll see the breakdown point, and what the error/problem is. Makes it easier to troubleshoot.

Try the xcopy command instead of copy by the way. And for help with any command type the command name /? for help.

i.e. xcopy /?

Matt J.
 
Copy /-Y G:\Source\File.mdb G:\Destination\Backup.mdb

Will do the exact same thing, but faster

Marc
If 'something' 'somewhere' gives 'some' error, expect random guesses or no replies at all. Please specify details.
Free Tip: The F1 Key does NOT destroy your PC!
 
Thanks, Marc and Matt! In the process of using Matt's help, I had discovered the /Y and /-Y option, which is great. I have also changed it to xcopy and it seems to be working fine now.
One more thing... Even though I am using a file extension on the destination, it's prompting me to specify whether the target is a directory or a file, and I have to type "f" or "d". Is there a way to automatically answer this question (so the user won't get the prompt)?
Thanks again!
Patricia
 
Never mind about the automatic prompt thing. I found the /i switch.

Thanks, guys, for your helpful advice and info.
 
If you are going to do this on a regular basis, please spend a little time looking on this site for suggestions and download this freeware tool:
With a little time on spent on the various switches available, you can do incredible things with this freeware tool.

Recommended highly.
Best,
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top