Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- SET BaseDir=c:Users
- SET BkpsDir=d:Backup
- IF NOT EXIST "7za.exe" GOTO ExitError
- IF NOT EXIST "nircmd.exe" GOTO ExitError
- SET TimeFile=%temp%tmpCloneFileTimeFile.bkp
- SET OutputFile=%temp%tmpOutputFile.bkp
- REM create a temporary file
- copy /y NUL "%TimeFile%" 1>NUL
- CALL :CompressDirIfChanged PublicMusic PublicMusic.7z
- CALL :CompressDirIfChanged DragosFavorites DragosFavorites.7z
- DEL "%TimeFile%" /F /Q >nul 2>nul
- DEL "%OutputFile%" /F /Q >nul 2>nul
- ECHO.
- ECHO SUCCESS
- ECHO.
- PAUSE
- EXIT
- goto:eof
- REM call :CompressDirIfChanged sourceDirRelativeToBaseDir ArchiveName
- :CompressDirIfChanged
- SET BkpSrc="%~1"
- SET ArchDest=%BkpsDir%%~2
- CD "%BaseDir%"
- IF EXIST "%ArchDest%" (
- nircmd.exe clonefiletime "%ArchDest%" "%TimeFile%"
- 7za.exe u -up1q0r2x2y2z1w2 -mx=9 "%ArchDest%" "%BkpSrc%" | FINDSTR /b "Items to compress:" 1>"%OutputFile%"
- IF errorlevel 1 GOTO ExitError
- REM FINDSTR /b "Items to compress: *0" "c:UsersDragosAppDataLocalTemptmpOutputFile" 1>NUL
- FINDSTR /b "Items to compress: *0" "%OutputFile%" 1>NUL
- IF errorlevel 1 (
- ECHO - updating %ArchDest%
- ) ELSE (
- ECHO - no changes in %BkpSrc%, restoring Last Modified Time
- nircmd.exe clonefiletime "%TimeFile%" "%ArchDest%"
- )
- ) ELSE (
- ECHO - creating %ArchDest%
- 7za.exe a -aoa -mx=9 "%ArchDest%" "%BkpSrc%" 1>nul
- IF errorlevel 1 GOTO ExitError
- )
- goto:eof
- :ExitError
- ECHO ERROR!
- PAUSE
- EXIT 1
- goto:eof
Add Comment
Please, Sign In to add comment