# Batch and Xcopy



## PVTCaboose1337 (Aug 31, 2009)

My objective is to create a program that copies data in my documents, and then puts it onto an external drive.  

My code I think I should do is:  

@xcopy /e /y "C:\Users\PVTCaboose1337\Documents\School" "M:/School"

Yet is does not work.  In this instance, I am trying to put the folder "school" into drive M which is my external hard drive.


----------



## FordGT90Concept (Aug 31, 2009)

Try moving /E and /Y to after the paths...

@xcopy "C:\Users\PVTCaboose1337\Documents\School" "M:/School" /E /Y

It must always be:

xcopy source destination [options]


----------



## newtekie1 (Aug 31, 2009)

I would use Robocopy, and put the switches/options after the source/destination.


----------



## PVTCaboose1337 (Aug 31, 2009)

FordGT90Concept said:


> Try moving /E and /Y to after the paths...
> 
> @xcopy "C:\Users\PVTCaboose1337\Documents\School" "M:/School" /E /Y
> 
> ...



Problem solved!  Also on the M: part, I had a forward slash instead of the backward slash I should have had!


----------



## FordGT90Concept (Aug 31, 2009)

Indeed, Windows generally doesn't care if it is a forward or backslash but consistency is always a good thing.


----------

