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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a batch file to copy one .mdb to another location 1

Status
Not open for further replies.

pewilson

Technical User
Mar 9, 2001
52
US
Im in the process of trying to teach myself how to create a batch file to copy a .mdb file from one location to another location (i.e. to another drive). But up to this point I have had little success in finding good examples to create a batch file to aid me. Can anyone out there offer their skills to help me?

Thanks in advance

PW
 
You can create a batch file by using Notepad, WordPad, or any other plain text editor. Simply type in the MS-DOS commands, one per line, and save the file with a ".bat" extension.

To get help on an MS-DOS command, open an MS-DOS window and type at the command prompt: <command name> /?

To copy a specific file from one specific location to another, use the MS-DOS Copy command:
copy C:\xxx\xxx\filename.ext D:\xxx\xxx

If you need to plug in the path or file name dynamically, I'm afraid that's quite difficult with batch files. It can be done using a hierarchy of nested batch commands, temporary files, and redirection operators, but it's not for beginners (and I'm not sure anybody even remembers how any more, so you might well have to work it out on your own). If you really must do this, you might want to check second hand bookstores for old books like &quot;Running MS-DOS&quot;. Some such books had good techniques for making flexible batch files. Rick Sprague
 
One extra point - are you trying to call the batch file from within the database that you are trying to copy? If so you need to be sure there are no open records as locking problems may occur. To run the batch file from within access you could use the shell command in code or the run application in a macro. In fact you could also have the copy as an argument such as &quot;xcopy c:\mydir\mydb.mdb d:\mydir\newdb.mdb&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top