Advertisement
crescentfresh

Backup Projects

Jun 25th, 2023
2,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. setlocal
  3.  
  4.  
  5. REM Set the path to the folder you want to compress
  6. set "folder=E:\MainProject"
  7.  
  8. REM Set the destination folder for the compressed file
  9. set "destination=E:\Backups"
  10.  
  11. REM Set the new destination folder to copy the compressed file
  12. set "newDestination=Y:\Unity Stuff\Backups"
  13.  
  14. REM Get the current date and time in the format YYYY-MM-DD-HH-MM
  15. for /f "tokens=1-6 delims=/: " %%a in ("%date% %time%") do (
  16.   set "datestamp=%%a-%%b-%%c-%%d-%%e-%%f"
  17. )
  18.  
  19. REM Remove leading zeros from minute
  20. set "minute=%datestamp:~-2%"
  21. if "%minute:~0,1%"=="0" set "minute=%minute:~1%"
  22.  
  23. REM Change the current working directory to the destination folder
  24. cd /d "%destination%"
  25.  
  26. REM Compress the folder using 7zip with maximum compression
  27. 7z a -t7z -m0=lzma2 -mx9 -mfb=64 -md=32m -ms=on "MainProject_%datestamp%.7z" "%folder%"
  28.  
  29. REM Open the destination folder in Windows Explorer
  30. explorer "%destination%"
  31.  
  32. REM Copy the compressed file to the new destination folder
  33. copy "MainProject_%datestamp%.7z" "%newDestination%"
  34.  
  35. endlocal
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement