Paste the following code into a .bat text file to create a runnable script that copies your DropBox folder contents to a specified folder on any removable drives (D: thru H:) present. This excludes the dropbox cache and other hidden and system files. Double-click the batch file or run from the command line. You can change the destination folder name (after ‘Destination=’) or the source dropbox folder location if different (“%USERPROFILE%\Dropbox”). You could also edit the example file (‘Excludefile.123’) to exclude other files or file types (like ‘*.zip’) or directories (add to ‘.dropbox.cache’) – use spaces to separate multiple entries – see Robocopy for more information. A log file is created in the root of the destination drive recording what was done.
@ECHO OFF
TITLE Backup
REM
SET Destination=FolderOnUSB
SET Counter=0
ECHO.
ECHO DropBox BackUp Job to folder '%Destination%' on removable USB drives
ECHO *** Excluding hidden '.dropbox.cache' folder, system files ***
ECHO.
ECHO *** WARNING files-in-use may be skipped ***
CALL :SleepSeconds 5
REM loop thru drive letters
FOR %%x in (D E F G H) DO (CALL :CopyToDrive %%x)
REM
ECHO Finished - Drives updated = %Counter%
ECHO.
TIMEOUT 10
EXIT /B %ERRORLEVEL%
REM
REM **************Functions*****************
:CopyToDrive
SET DriveLetter=%~1
REM ECHO Searching for %DriveLetter%:\%Destination%
IF EXIST "%DriveLetter%:\%Destination%\" (
ECHO %DriveLetter%: Data Drive updating
CALL :SleepSeconds 5
ROBOCOPY "%USERPROFILE%\Dropbox" "%DriveLetter%:\%Destination%" /MIR /FFT /Z /NP /TEE /XA:H /XD .dropbox.cache /W:5 /XJ /XF ExcludeFile.123 /NFL /log:"%DriveLetter%:\%Destination%-CopyLog.txt"
set /a Counter=%Counter%+1)
REM
ECHO.
EXIT /B 0
REM ========================================
:SleepSeconds
SET DelaySec=%~1
TIMEOUT /T %DelaySec% /NOBREAK > nul
EXIT /B 0