@echo off
setLocal EnableDelayedExpansion
:: ------------------------ SET VARIABLES (don't touch) ----------------------------
set LauncherFolder="%userprofile%\Documents\Rockstar Games\Launcher"
:: ------------------------ USER OPTIONS ----------------------------------------------
:: 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!
set backupfolder=gamefolder\_backup
:: ----------------------------------------------------------------------------------------
:Start
:GetGameFolder
if exist %LauncherFolder% (
cd /d %LauncherFolder%
for /f tokens^=2^ delims^=^" %%i in ('type launcher.log ^|find "GTA5.exe"') do set "exepath=%%i"
if "!exepath!"=="" ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
set gamepath="!exepath:\GTA5.exe=!"
if exist !gamepath! ( set "gamefolder=!gamepath!" ) else ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
echo Detected Game Folder !gamepath! & echo.
) else ( echo Warning: CAN'T FIND LAUNCHER FOLDER %LauncherFolder% & pause & goto :eof )
:GetVersion
set exepath2=!exepath:\=\\!
for /f "tokens=*" %%V in ( ' wmic datafile where "name='!exepath2!'" get version ' ) do (
for /F "delims=" %%A IN ("%%V") do (
if not "%%V"=="" (
if not "%%V"=="Version" set "version=%%V"
)
)
)
set "version=%version: =%"
if '!version!'=='' ( echo ERROR: COULD NOT DETECT VERSION & pause & goto :eof ) else ( echo Game Version: %version% )
:GetPlatform
cd /d %LauncherFolder%
if exist launcher.log (
for /f "tokens=*" %%i in ('type launcher.log ^|find "Running in Steam mode"') do set "Is_Steam=true"
) else (
echo ERROR: CAN'T FIND %cd%\launcher.log
)
:SetFileList
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 )
:CheckBackupFolder
set backupfolder=%backupfolder:gamefolder=!gamefolder!%
set backupfolder=%backupfolder:"=%
set backupfolder="%backupfolder%"
if exist %backupfolder% (
echo. & echo Backup Folder %backupfolder%
set bkup_count=0
cd /d %backupfolder%
for /f "tokens=* delims= " %%A in ( ' dir /b /-p /a:d /o:-n /t:w *.* ' ) do (
set "var=" & for /f "delims=.0123456789" %%i in ('echo %%A') do set var=%%i
if "!var!"=="" (
set "var="
set /a bkup_count=!bkup_count!+1
if not "!backups!"=="" ( set "backups=!backups!,%%A") else ( set "backups=%%A")
echo found backup %%A
)
)
if !bkup_count!==0 echo NO BACKUPS HAVE BEEN FOUND. EXITING. & pause & goto :eof
) else ( echo ERROR: CAN'T FIND BACKUPFOLDER & pause & goto :eof )
:CheckGameFiles
echo. & echo Game Folder files: & echo.
echo GTA5.exe = %version% (actual version)
for %%F in (%files_tocopy%) do (
if /i not %%F==gta5.exe (
for /f "delims=" %%i in ('certutil -v -hashfile %gamefolder%\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash1=%%i"
CALL :CompareFileToBackups %%F
)
)
:CompareAllBackups
set bkup1=
cd /d %backupfolder%
echo. & echo. & echo Comparing Files Between Backups...
for %%A in (%backups%) do (
if '!bkup1!'=='' ( set bkup1=%%A ) else (
CALL :Compare_bkup2bkup !bkup1! %%A
set bkup1=%%A
)
)
:Finished
echo. & echo.
echo --------------------------------------------------
echo Finished.
echo --------------------------------------------------
echo.
pause
goto :eof
:Compare_bkup2bkup
cd /d %backupfolder%
echo.
echo --------------------------------------------------
echo %1 ^<=^> %2
echo.
for %%F in (%files_tocopy%) do (
set hash1=
set hash2=
for /f "delims=" %%i in ('certutil -v -hashfile %1\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash1=%%i"
for /f "delims=" %%i in ('certutil -v -hashfile %2\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash2=%%i"
if !hash1!==!hash2! (
echo %%F = %%F
) else (
echo %%F ^^!= %%F
)
)
goto :eof
:CompareFileToBackups
cd /d %backupfolder%
for %%A in (%backups%) do (
for /f "delims=" %%i in ('certutil -v -hashfile %backupfolder%\%%A\%1 MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash2=%%i"
if !hash1!==!hash2! (
echo %1 = %%A (as compared to backups^)
goto :eof
)
)
echo %1 = unknown
goto :eof