Skip to content

Instantly share code, notes, and snippets.

@ThisIsArnab
Last active March 14, 2021 17:29
Show Gist options
  • Save ThisIsArnab/9a589351150e5b6d6ac094d893191cac to your computer and use it in GitHub Desktop.
Save ThisIsArnab/9a589351150e5b6d6ac094d893191cac to your computer and use it in GitHub Desktop.
Robocopy script to copy only new or modified files to destination.
:: Version 1.0
@echo off
REM for first argument
if "%~1"=="" ( :: if no arguments are provided ask the user for the arguments
set /p source="Enter source directory location: "
)else ( :: set the variables as per the values of the parameters
set source=%~1
)
REM for second argument
if "%~2"=="" ( :: if no arguments are provided ask the user for the arguments
set /p destination="Enter destination directory location: "
)else ( :: set the variables as per the values of the parameters
set destination=%~2
)
REM Do the robocopy update stuff
robocopy "%source%" "%destination%" /XO /L >CON
set /p userChoice="Proceed? (y/n): "
set "goAhead="
if "%userChoice%"=="y" set goAhead=1
if "%userChoice%"=="Y" set goAhead=1
if %goAhead% equ 1 (
robocopy "%source%" "%destination%" /XO >CON
) else (
echo Aborted Operation
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment