Guest User

Untitled

a guest
Jan 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. @ECHO OFF
  2.  
  3.  
  4. SET BaseDir=c:Users
  5. SET BkpsDir=d:Backup
  6.  
  7.  
  8. IF NOT EXIST "7za.exe" GOTO ExitError
  9. IF NOT EXIST "nircmd.exe" GOTO ExitError
  10. SET TimeFile=%temp%tmpCloneFileTimeFile.bkp
  11. SET OutputFile=%temp%tmpOutputFile.bkp
  12.  
  13. REM create a temporary file
  14. copy /y NUL "%TimeFile%" 1>NUL
  15.  
  16.  
  17. CALL :CompressDirIfChanged PublicMusic PublicMusic.7z
  18. CALL :CompressDirIfChanged DragosFavorites DragosFavorites.7z
  19.  
  20.  
  21. DEL "%TimeFile%" /F /Q >nul 2>nul
  22. DEL "%OutputFile%" /F /Q >nul 2>nul
  23.  
  24. ECHO.
  25. ECHO SUCCESS
  26. ECHO.
  27. PAUSE
  28. EXIT
  29. goto:eof
  30.  
  31.  
  32. REM call :CompressDirIfChanged sourceDirRelativeToBaseDir ArchiveName
  33. :CompressDirIfChanged
  34. SET BkpSrc="%~1"
  35. SET ArchDest=%BkpsDir%%~2
  36. CD "%BaseDir%"
  37. IF EXIST "%ArchDest%" (
  38. nircmd.exe clonefiletime "%ArchDest%" "%TimeFile%"
  39. 7za.exe u -up1q0r2x2y2z1w2 -mx=9 "%ArchDest%" "%BkpSrc%" | FINDSTR /b "Items to compress:" 1>"%OutputFile%"
  40. IF errorlevel 1 GOTO ExitError
  41. REM FINDSTR /b "Items to compress: *0" "c:UsersDragosAppDataLocalTemptmpOutputFile" 1>NUL
  42. FINDSTR /b "Items to compress: *0" "%OutputFile%" 1>NUL
  43. IF errorlevel 1 (
  44. ECHO - updating %ArchDest%
  45. ) ELSE (
  46. ECHO - no changes in %BkpSrc%, restoring Last Modified Time
  47. nircmd.exe clonefiletime "%TimeFile%" "%ArchDest%"
  48. )
  49. ) ELSE (
  50. ECHO - creating %ArchDest%
  51. 7za.exe a -aoa -mx=9 "%ArchDest%" "%BkpSrc%" 1>nul
  52. IF errorlevel 1 GOTO ExitError
  53. )
  54. goto:eof
  55.  
  56. :ExitError
  57. ECHO ERROR!
  58. PAUSE
  59. EXIT 1
  60. goto:eof
Add Comment
Please, Sign In to add comment