Advertisement
Urik_Kane

GTAV_check_backups.bat

Jun 18th, 2019
2,669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.32 KB | None | 0 0
  1. @echo off
  2. setLocal EnableDelayedExpansion
  3.  
  4. :: ------------------------ SET VARIABLES (don't touch) ----------------------------
  5. set LauncherFolder="%userprofile%\Documents\Rockstar Games\Launcher"
  6.  
  7. :: ------------------------ USER OPTIONS ----------------------------------------------
  8. :: gamefolder will be replaced by actual game folder. BUT, you can put a completely custom path here, like "F:\my backups\gta_backup" , BUT please use " marks if your path has spaces!
  9. set backupfolder=gamefolder\_backup
  10. :: ----------------------------------------------------------------------------------------
  11.  
  12.  
  13. :Start
  14. :GetGameFolder
  15. if exist %LauncherFolder% (
  16. cd /d %LauncherFolder%
  17. for /f tokens^=2^ delims^=^" %%i in ('type launcher.log ^|find "GTA5.exe"') do set "exepath=%%i"
  18. if "!exepath!"=="" ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  19. set gamepath="!exepath:\GTA5.exe=!"
  20. if exist !gamepath! ( set "gamefolder=!gamepath!" ) else ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  21. echo Detected Game Folder !gamepath! & echo.
  22. ) else ( echo Warning: CAN'T FIND LAUNCHER FOLDER %LauncherFolder% & pause & goto :eof )
  23.  
  24. :GetVersion
  25. set exepath2=!exepath:\=\\!
  26. for /f "tokens=*" %%V in ( ' wmic datafile where "name='!exepath2!'" get version ' ) do (
  27.  
  28.     for /F "delims=" %%A IN ("%%V") do (
  29.         if not "%%V"=="" (
  30.             if not "%%V"=="Version" set "version=%%V"  
  31.         )
  32.     )
  33. )
  34. set "version=%version: =%"
  35. if '!version!'=='' ( echo ERROR: COULD NOT DETECT VERSION & pause & goto :eof ) else ( echo Game Version: %version% )
  36.  
  37. :GetPlatform
  38. cd /d %LauncherFolder%
  39.     if exist launcher.log (
  40.     for /f "tokens=*" %%i in ('type launcher.log ^|find "Running in Steam mode"') do set "Is_Steam=true"
  41.     ) else (
  42.     echo ERROR: CAN'T FIND %cd%\launcher.log
  43. )
  44.  
  45. :SetFileList
  46. if defined is_steam ( set files_tocopy=GTA5.exe,GTAVLauncher.exe,steam_api64.dll,update\update.rpf ) else ( set files_tocopy=GTA5.exe,GTAVLauncher.exe,update\update.rpf )
  47.  
  48. :CheckBackupFolder
  49. set backupfolder=%backupfolder:gamefolder=!gamefolder!%
  50. set backupfolder=%backupfolder:"=%
  51. set backupfolder="%backupfolder%"
  52. if exist %backupfolder% (
  53.     echo. & echo Backup Folder %backupfolder%
  54.     set bkup_count=0
  55.     cd /d %backupfolder%
  56.     for /f "tokens=* delims= " %%A in ( ' dir /b /-p /a:d /o:-n /t:w *.* ' ) do (  
  57.         set "var=" & for /f "delims=.0123456789" %%i in ('echo %%A') do set var=%%i
  58.         if "!var!"=="" (
  59.             set "var="
  60.             set /a bkup_count=!bkup_count!+1
  61.             if not "!backups!"=="" ( set "backups=!backups!,%%A") else ( set "backups=%%A")
  62.             echo found backup %%A
  63.         )
  64.     )
  65.     if !bkup_count!==0 echo NO BACKUPS HAVE BEEN FOUND. EXITING. & pause & goto :eof
  66. ) else ( echo ERROR: CAN'T FIND BACKUPFOLDER & pause & goto :eof )
  67.  
  68. :CheckGameFiles
  69. echo. & echo Game Folder files: & echo.
  70. echo GTA5.exe           = %version%   (actual version)
  71. for %%F in (%files_tocopy%) do (
  72.     if /i not %%F==gta5.exe (
  73.         for /f "delims=" %%i in ('certutil -v -hashfile %gamefolder%\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash1=%%i"
  74.         CALL :CompareFileToBackups %%F
  75.     )
  76. )
  77.  
  78. :CompareAllBackups
  79. set bkup1=
  80. cd /d %backupfolder%
  81. echo. & echo. & echo Comparing Files Between Backups...
  82. for %%A in (%backups%) do (
  83.     if '!bkup1!'=='' ( set bkup1=%%A ) else (
  84.     CALL :Compare_bkup2bkup !bkup1! %%A
  85.     set bkup1=%%A
  86.     )
  87. )
  88.  
  89. :Finished
  90. echo. & echo.
  91. echo --------------------------------------------------
  92. echo Finished.
  93. echo --------------------------------------------------
  94. echo.
  95. pause
  96. goto :eof
  97.  
  98. :Compare_bkup2bkup
  99. cd /d %backupfolder%
  100. echo.
  101. echo --------------------------------------------------
  102. echo %1 ^<=^> %2
  103. echo.
  104. for %%F in (%files_tocopy%) do (
  105.     set hash1=
  106.     set hash2=
  107.     for /f "delims=" %%i in ('certutil -v -hashfile %1\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash1=%%i"
  108.     for /f "delims=" %%i in ('certutil -v -hashfile %2\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash2=%%i"
  109.     if !hash1!==!hash2! (
  110.     echo %%F           = %%F
  111.     ) else (
  112.     echo %%F         ^^!= %%F
  113.     )
  114. )
  115. goto :eof
  116.  
  117. :CompareFileToBackups
  118. cd /d %backupfolder%
  119. for %%A in (%backups%) do (
  120.     for /f "delims=" %%i in ('certutil -v -hashfile %backupfolder%\%%A\%1 MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash2=%%i"
  121.     if !hash1!==!hash2! (
  122.     echo %1   = %%A   (as compared to backups^)
  123.     goto :eof
  124.     )
  125. )
  126. echo %1   = unknown
  127. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement