Using XCOPY to Synchronize Folders

While there are many more advanced tools for synchronizing folders, one very useful method (on Windows OS) is to use the XCOPY command. The XCOPY command has been part of the windows suite since the DOS days, and provides a helpful set of options that the standard COPY command does not.

If you are in an environment where you have several mobile devices generating content that you would like stored on a central server for backup and group collaboration, the XCOPY command can be a simple solution for performing regular migrations of the new / updated content on your mobile device.

The XCOPY command for copying the updates from one folder to another is as follows:

C:\> XCOPY C:/SOURCE D:/DESTINATION /E /D /C /Y

The flags used in the above example define:

  • /E
    This flag causes all folders and sub-folders to be copied
  • /D
    This flag causes a DATE comparison to be made, only copying items that are newer than the DESTINATION item. If the DESTINATION is older, or does not contain the file, then it will be copied.
  • /C
    This flag tells XCOPY to continue if it encounters an error - typically errors occur with read-only files, or files that have protected permissions
  • /Y
    This flag tells XCOPY to suppress prompting you for confirmation, which is necessary if you intend to create an automation script or scheduled task

If you wish to automate this process, the easiest method is to create a BATCH file and then create either a SCHEDULED TASK, WINDOWS USER LOGIN SCRIPT or a SHORTCUT to the batch file that you would manually run when you connect your device.

To create a BATCH file, you will:

  1. Open Notepad
    Start -> Accessories -> Notepad
  2. Type or Copy the following into the blank document
    @echo OFF
    echo :
    echo : XCOPY Batch Process Started
    echo :
    xcopy {SOURCE_PATH} {DESTINATION_PATH} /E /D /C /Y
    echo :
    echo : XCOPY Batch Process Complete
    echo :
  3. Save the file as XCOPY_AUTO.BAT somewhere where you can find it. If you don't know where to put it, just save it on your desktop.

Scheduled Tasks and Login Scripts are a bit harder and if you've gotten this far, you should be able to perform a google and find instructions for further automation.

Good Luck and Happy Coding!

 


  • 31 Users Found This Useful
Was this answer helpful?

Related Articles

View your Clipboard History

What an amazing and simple idea - view a history of the things you copied onto your...

ShowMan Disk Space Usage Graph Visualizer

Disk Space Analyzer and Disk Usage Graph Years ago when I received my first computer, I started...

Windows Hot-Keys for Quick Control

Most computer users have had limited experience with Hot-Keys. The concept of the hot-key is...

Image Resizer for Windows XP / Vista

Microsoft PowerToys for Windows XP have been a godsend for many of us.  Unfortunately, they...

Windows Vista - Shrink and Partition Your Disk

This article will guide you through the process of cleaning your hard disk and shrinking your...

Disqus this...

comments powered by Disqus