Pappy’s

Back Camera

  • Camera: iPhone
  • Taken: 16 August, 2010
  • Aperture: ƒ/2.4
  • Focal length: 3.85mm
  • ISO: 500
  • Shutter speed: 1/15s
  • Title: Back Camera

Using XCopy and excluding files and or directories

I use XCopy to back stuff up because it’s fast and easy.  Until you add 11,898 files you don’t want to actually backup.
So I set about trying to figure out how to exclude directories and or files from the XCopy routine.

It turned out to be pretty easy.

I basically have 2 text files.  RunBackup.cmd and MyExcludes.txt
They both reside in the same folder. 
The RunBackup.cmd text file has just the following line in it (all one line no line breaks):

xcopy /E /Y “C:\MySourceDirectory\subdirectory” “G:\MyDestinationDirectory\subdirectory\” /EXCLUDE:MyExcludes.txt

The MyExcludes.txt has the following line in it:

\Storage\

So this backs up everything in the source directory including subdirectories to the destination directory but excludes anything in a directory called \Storage and all sub-directories and files below that.

You can also put (each on a seperate line) things like:

\Storage\
.doc
.pdf

That would do the same as above but also exclude any .doc and .pdf files from any directories in the source.
Tested on Windows 7 Professional.