USB Sync Utility

Well, not so much a utility as it is a batch file.  But what I’ve tried to do here is write a batch file that will locate a USB drive in the system and backup files to it.

You will need “robocopy” from the Windows Resource Kit (most any version will do nicely); I’ve though about converting it to rsync (Cygwin), but I’ve found that rsync isn’t really that much faster than robocopy for binary files (and mostly I use this to sync media files).

Here’s what you will need to change:

LABEL, that’s the volume label for the USB drive you want to back up to; hopefully you use unique labels for all your USB thumb drives, external USB hard drives, etc — if not, this batch file won’t have much value

TARGET, that’s the sub-directory where you want the backup to be on the external drive (it should be relative to the root of the drive, but shouldn’t start with a back slash or drive designation.

the “sync.bat” file should go in the root of the directory that is to be backed up (that’s how it locates the source) and you just double click it in the Windows Explorer to launch it .


@echo off
rem sync files to backup
set TARGET=Target
set USB=

for /f %%D in (‘wmic volume get DriveLetter^, Label ^| find “%LABEL%”‘) do set USB=%%D

if "" == "%USB%" (
  echo "Volume `%LABEL%` not found"
) else (
  echo "Backup `%CD%` to `%USB%\%TARGET%`"
  robocopy /MIR %CD%\ %USB%\%TARGET%



Download sync.bat (as a 7z file)

Download sync.bat (as a ZIP file)