Batch script to make backup folder. only new and modified files

ilansch picture ilansch · Jul 1, 2012 · Viewed 57.4k times · Source

I need a script to copy only the changed/modified and new files from my C:\Dropbox to my C:\backup. Why does this copy only the folder structure:

@echo off

set destination=C:\Backup
set source=C:\Users\XXXX\Dropbox\Intranet

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd1=%%j"."%%i"."%%k

xcopy %source%"\*" %destination%"\*" /m/e/y
mkdir %destination%"\LastBackupDate %yyyymmdd1%"
echo A folder containing the latest date has been created in root directory of %source%.
echo Finished copying %source% to %destination%
echo.
pause

Answer

ilansch picture ilansch · Jul 1, 2012
ECHO OFF
set source=C:\Users\xxxx\Dropbox\
set destination=C:\Backup\

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd1=%%j"."%%i"."%%k

if exist %destination% goto GO
:GO
mkdir %destination%%yyyymmdd1%
xcopy %source%* %destination% /s/d/y/c/v/r
echo. 
echo Finished copying %source% to %destination%
echo.
echo Created %destination%%yyyymmdd1%
pause