Advertisement
Urik_Kane

GTAV_rename_last_exported

Jun 25th, 2019
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.23 KB | None | 0 0
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3.  
  4. :: ----------- SETTINGS -------------------------------------------------------
  5. :: which extension your videos are?
  6. set extensions=avi,mov,wav
  7. :: whether to open export folder after renaming
  8. set open_exportfolder=true
  9. :: whether to delete original mp4 files anyway, even if not files to rename found
  10. set del_mp4_anyway=true
  11. :: ----------- SETTINGS END -------------------------------------------------
  12.  
  13. :: path variables
  14. set GTAVfolder="%userprofile%\Documents\Rockstar Games\GTA V"
  15. set SCfolder="%userprofile%\Documents\Rockstar Games\Social Club"
  16. set vidfolder="%localappdata%\Rockstar Games\GTA V\videos\rendered"
  17. set evefolder=eve
  18.  
  19. :GetGameFolder
  20. if exist %GTAVfolder% (
  21. cd /d %GTAVfolder%
  22. for /f "tokens=2 delims=(" %%i in ('type launcher.log ^|find "GTA5.exe)"') do set "gamepath=%%i"
  23. if "!gamepath!"=="" ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  24. set gamepath=!gamepath:for =!
  25. set gamepath="!gamepath:\GTA5.exe)=!"
  26. if exist !gamepath! ( set "gamefolder=!gamepath!" ) else ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  27. ) else ( echo Warning: CAN'T FIND GTA USER FOLDER %GTAVfolder% & pause & goto :eof )
  28.  
  29. :SetEVEFolder
  30. set gamefolder=%gamefolder:"=%
  31. set EVEfolder="%gamefolder%\EVE"
  32. if NOT exist %EVEfolder% echo COULD NOT FIND EVE FOLDER & pause & goto :eof
  33. echo EVE folder detected: %EVEfolder% & echo.
  34.  
  35. :GetExportFolder
  36. cd /d %EVEfolder%
  37. for /f "tokens=3 delims= " %%i in ('type ExtendedVideoExport.ini ^|find "output_folder"') do set "ExportFolder=%%i"
  38. echo export folder detected: !ExportFolder!
  39. if "!ExportFolder!"=="" ( echo COULD NOT AUTODETECT EXPORT FOLDER & pause & goto :eof )
  40. if not exist !ExportFolder! ( echo EXPORT FOLDER INVALID OR DOESN'T EXIST & pause & goto :eof )
  41.  
  42.  
  43. :: set rockstar rendered videos folder
  44. cd /d %vidfolder%
  45.  
  46. :: we're using for loop and dir command to sort files by date and get the most recent one
  47. for /f "tokens=* delims= " %%A in ( ' dir /b /-p /o:-d /t:w *.mp4 ' ) do (
  48.     REM if not "!lastname!"=="" goto :eof
  49.     set "lastname=%%~nA"
  50.     goto :Rename
  51. )
  52. :: this will only print if there were no mp4 files in the folder
  53. echo -------------------------------------------------------------------------------------------------------
  54. echo ERROR: NO MP4 FILES FOUND IN %vidfolder%
  55. echo -------------------------------------------------------------------------------------------------------
  56. pause
  57. goto :eof
  58.  
  59. :: set the path of your custom extended video export output_folder
  60. :Rename
  61. cd /d %exportfolder%
  62. echo %cd%
  63. :: same as before, use for loop and dir to get the most recent file which name starts with EVE, then rename it to the name we stored earlier in !vidname! variable
  64. for /f "tokens=* delims= " %%A in ( ' dir /b /-p /o:-d /t:w *.* ' ) do (
  65.     if !renamed!==true exit
  66.     set evefileext=%%~xA
  67.     set evefilename=%%~nA
  68.     set evefilename=!evefilename:~0,3!
  69.     for %%E in (%extensions%) do (
  70.         if !evefileext!==.%%E (
  71.             if !evefilename!==EVE (
  72.                 ren "%%A" "!lastname!%%~xA"
  73.                 if !errorlevel!==0 ( CALL :ReportRenameSuccess %%~nxA !lastname!%%~xA ) else ( CALL :ReportRenameFailure %%~nxA )
  74.                 goto :eof
  75.             )
  76.         )
  77.     )
  78. )
  79. :: this will only print if no suitable file (matching the criteria) found
  80. echo ---------------------------------------------------------------
  81. echo ERROR: NO SUITABLE %extensions% FILES TO RENAME
  82. echo ---------------------------------------------------------------
  83. if %del_mp4_anyway%==true CALL :Deletemp4
  84. pause
  85. goto :eof
  86.  
  87. :ReportRenameFailure
  88. echo ---------------------------------------------------------------------------------------
  89. echo  ERROR
  90. echo  CAN'T RENAME FILE %1
  91. echo  CHECK PERMISSIONS
  92. echo ---------------------------------------------------------------------------------------
  93. pause
  94. goto :eof
  95.  
  96. :ReportRenameSuccess
  97. echo ---------------------------------------------------------------------------------------
  98. echo  RENAMED FILE %1 to %2
  99. echo ---------------------------------------------------------------------------------------
  100. CALL :Deletemp4
  101. goto :Finish
  102. goto :eof
  103.  
  104. :Finish
  105. pause
  106. if %open_exportfolder%==true explorer %exportfolder%
  107. goto :eof
  108.  
  109. :: delete ALL files in the rockstar rendered videos folder
  110. :Deletemp4
  111. del %vidfolder%\*.mp4
  112. echo deleted mp4 files
  113. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement