Move Excel Files With Windows Script Xcopy

Do You Have Patience?

I don't. 

Previously, I wrote a tutorial on using task scheduler to backup Excel workbooks. This is a neat feature and works great - however running it needs Excel VBA which can cause issues.  

For example if you are currently working on an Excel workbook, when it runs you are unable to do anything for a few seconds. It can be a bothersome interruption. 

Secondly, if you aren't using Excel it needs to launch the program. This takes time, and then you are left with an empty Excel window begging you to use it. This is emotional abuse I just can't take. 

What can I do?!

Well, thanks to Uncle Google I found a cool little built in Windows script called Xcopy. Using CMD, you can efficiently copy anything to anywhere. You won't even notice it run (unless you have something huge). 

1. Create a folder on your desktop called "Move From Here". 
2. Create another folder on your desktop called "Move To Here". 
3. Create an Excel workbook in the first folder called "Excel Workbook - Important". 
4. Now open notepad and add in the following script, change your locations to match your own. 

xcopy "C:\Users\Your User Name\Desktop\Move From Here\Excel Workbook - Important.xlsx" "C:\Users\Your User Name\Desktop\To Here" /y pause 

5. Save the notepad file anywhere, but add .bat to the end. So "Notepad.bat". This will tell Windows it is a script and run it with CMD. 
6. Double click on your new bat file. You should see the following pop up:

Xcopy script.png

Simple as that. If you remove the pause from the code, the CMD window won't stay open. 


Wow! How Can I Make This Even Better?

By setting up Task Scheduler! Go and look at the Excel Task Scheduler Tutorial - only when you reach the Action Tab, don't add an Argument and just use the browse button to add your Bat file. Couldn't be easier. 

Microsoft have a great article on Xcopy, have a read to find all the cool commands you can do, if the above doesn't quite do what you want. Start by finding out what the /y does in the above code.

If you use a separate computer (like a VM) to run your macros/scripts, this article is sort of irrelevant. However if you run them on the computer you use (like me), this is a much better option. My next step is to get the above code to add in a Timestamp!