Batch Copy Script

To combat the issue of Revit users overwriting shared coordinates of files linked into their Revit model. I’ve started linking copies of central files into all the models. If someone does overwrite coordinate information, the next day a new copy of the model overwrites the file with the correct information. The process involves creating a batch file that will copy files from one location to another and using windows task scheduler to run that task periodically. I thought this would be a good share.

Create a batch file

  • Right click and create a new text document. I usually do this in the project folder1 - Create Text File
  •  In the text file you need to type a command line. The command for copy is xcopy

In the text file, you need to type:

xcopy “path for files to copy from\*.RVT” “path for files to copy to”/y

The path for the files does need to be the full network path and will not work from your local directory. The \*.RVT at the end of the path is looking for any file that ends with .RVT and will copy those files to the specified path.

  • Save the file as a batch file. Click File/Save As, name the file and add .bat at the end.2 - Save As BAT
  • To test the file, double-click the newly created batch file. You should see a command prompt listing the files being copied.

2 - Command Line

Automate the task with Windows Task Scheduler

  • Open Windows Task Scheduler from your programs
  • Under the Actions Menu, Select Create Task…4 - Create Task
  • On the General tab, you’ll want to name the task descriptively and add a description to help you remember later. Update the security options as needed, I usually select Run whether user is logged on or not5 - General Tab
  • On the Triggers tab, click new you’ll specify how frequently you want to copy the files. This could be daily, weekly, or whatever you decide. You can add multiple triggers so if you would like the task to run twice per day you can add both times as seen below.6 - Triggers7 - Schedule
  • On the Actions tab is where we specify the actual task that is running. Click New8 - Actions
  • For the action, you want to run a program. For the program, you specify the .bat file that you created. Input: “Path to .bat file\Name of bat file.bat” Click Ok Until you’re back to the task scheduler welcome screen.9 - Start a Program
  • Rick-Click on the name of your task and select run to test your task10 - Run Task
  • Enjoy the Automation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s