@echo off setlocal EnableExtensions if "%~1"=="" goto usage if "%~2"=="" goto usage set "src=%~1" set "dst=%~2" if not exist "%src%\" ( echo Source folder not found: %src% exit /b 2 ) for %%i in ("%src%") do set "srcfull=%%~fi" for %%i in ("%dst%") do set "dstfull=%%~fi" if /I "%srcfull%"=="%dstfull%" ( echo Source and destination are the same. exit /b 2 ) set "mode=/L" if /I "%~3"=="run" set "mode=" if "%mode%"=="" ( echo Copying files without deleting anything. ) else ( echo Preview only. Add run as the third argument to copy. ) robocopy "%srcfull%" "%dstfull%" /E /COPY:DAT /R:1 /W:1 /NP /NDL %mode% set "code=%ERRORLEVEL%" if %code% GEQ 8 ( echo Robocopy failed with code %code%. exit /b %code% ) echo Robocopy finished with code %code%. exit /b 0 :usage echo Usage: backup-music.bat ^ ^ [run] exit /b 2