Advertisement
PowerBall253

ModLoader to Meathook batch

Jan 4th, 2021 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.55 KB | None | 0 0
  1. @echo off
  2. setlocal enableextensions
  3. cd /d "%~dp0"
  4.  
  5. :: Set scriptdir and make sure it ends with \
  6. set "scriptdir=%~dp0"
  7. if not "%scriptdir:~-1%"=="\" set "scriptdir=%scriptdir%\"
  8.  
  9. :: Check for config file
  10. if not exist "%scriptdir%ModLoader_to_Meathook.cfg" goto CreateConfig
  11.  
  12. :: Make sure the config file is valid
  13. :ConfigVerification
  14. (
  15.     set /p gamedir=
  16.     set /p replace=
  17. ) <"%scriptdir%ModLoader_to_Meathook.cfg"
  18. echo.%gamedir%|findstr /C:"GAMEDIR" >nul 2>&1
  19. if errorlevel 1 goto CreateConfig
  20. echo.%replace%|findstr /C:"REPLACE" >nul 2>&1
  21. if errorlevel 1 goto CreateConfig
  22. set "gamedir=%gamedir:GAMEDIR =%"
  23. if not "%gamedir:~-1%"=="\" set "gamedir=%gamedir%\"
  24. if not exist "%gamedir%DOOMEternalx64vk.exe" goto CreateConfig
  25. set "replace=%replace:REPLACE =%"
  26. set "replace=%replace: =%"
  27. goto Verification
  28.  
  29. :: Creates the config file
  30. :CreateConfig
  31. set /p "gamedir=Input your DOOMEternal directory (e.g.: C:\Program Files (x86)\Steam\steamapps\common\DOOMEternal): "
  32. if not "%gamedir:~-1%"=="\" set "gamedir=%gamedir%\"
  33. if not exist "%gamedir%DOOMEternalx64vk.exe" (
  34.     echo DOOM Eternal not found! Make sure you have the correct game path and try again.
  35.     goto Exit
  36. )
  37. echo GAMEDIR %gamedir%> "%scriptdir%ModLoader_to_Meathook.cfg"
  38. echo/
  39. echo/
  40. choice /c YN /m "Would you like this batch to automatically overwrite files when copying the overrides folder?"
  41. echo/
  42. echo/
  43. if errorlevel 1 (
  44.     set replace=1
  45. ) else (
  46.     set replace=0
  47. )
  48. echo REPLACE %replace% >> "%scriptdir%ModLoader_to_Meathook.cfg"
  49.  
  50.  
  51. :Verification
  52. :: Check if idFileDeCompressor is present
  53. if not exist "%scriptdir%idFileDeCompressor.exe" (
  54.     echo/
  55.     echo/
  56.     echo idFileDeCompressor was not found! Put idFileDecompressor.exe in the same folder as this batch, then try again.
  57.     echo/
  58.     echo/
  59.     goto Exit
  60. )
  61.  
  62. :: Check if oo2core_8_win64.dll is present
  63. if not exist "%scriptdir%oo2core_8_win64.dll" (
  64.     echo/
  65.     echo/
  66.     echo oo2core_8_win64.dll was not found! Put oo2core_8_win64.dll in the same folder as this batch, then try again.
  67.     echo/
  68.     echo/
  69.     goto Exit
  70. )
  71.  
  72. :: Remove previous overrides folder
  73. rmdir /s /q "%scriptdir%overrides"
  74.  
  75. :: Check for PowerShell
  76. 2>nul where /Q powershell
  77. if errorlevel 1 if not errorlevel 9009 goto 7zip
  78.  
  79. :: Unzip all mods to overrides folder using PowerShell
  80. :StartLoop1
  81. if "%~1" == "" goto PostExtraction
  82. powershell Expand-Archive '%~1' -DestinationPath '%scriptdir%overrides'
  83. shift
  84. goto StartLoop1
  85.  
  86. :7zip
  87. :: Check if 7zip is installed
  88. reg query HKLM\SOFTWARE\7-zip /v "Path"
  89. if not errorlevel 0 (
  90.     echo/
  91.     echo/
  92.     echo 7zip not found! Install 7zip, then try again.
  93.     echo/
  94.     echo/
  95.     goto Exit
  96. )
  97.  
  98. :: Read 7zip path from Registry and make sure it ends with \
  99. for /F "tokens=2* skip=2" %%a in (
  100.     'reg query "HKLM\SOFTWARE\7-zip" /v "Path"'
  101. ) do set "unzipperPath=%%b"
  102. if not "%unzipperPath:~-1%"=="\" set "unzipperPath=%unzipperPath%\"
  103.  
  104. :: Unzip all mods to overrides folder using 7zip
  105. :StartLoop2
  106. if "%~1" == "" goto PostExtraction
  107. "%unzipperPath%7z.exe" x -y -o"%scriptdir%overrides" "%~1"
  108. shift
  109. goto StartLoop2
  110.  
  111. :PostExtraction
  112. :: Delete any files in overrides directory like READMEs (to avoid errors with robocopy)
  113. del "%scriptdir%overrides\*.*" /q
  114.  
  115. :: Check for texture and blang files and delete them
  116. del "%scriptdir%overrides\*.tga" /q /s
  117. del "%scriptdir%overrides\*.png" /q /s
  118. del "%scriptdir%overrides\*.blang" /q /s
  119.  
  120. :: Copy all subfolders one dir up to delete .resources directories
  121. cd "%scriptdir%overrides"
  122. for /f "tokens=*" %%a in ('dir /b') do robocopy %%a . /S /IS /IT /IM /MOVE
  123.  
  124. :: Decompress .entities
  125. for /R "%scriptdir%overrides\maps\game" %%I in ("*.entities") do (
  126.     "%scriptdir%idFileDeCompressor.exe" -d "%%~fI" "%%~fI"
  127. )
  128.  
  129. :: Go back to scriptdir
  130. cd "%scriptdir%"
  131.  
  132. :: Ask if script should move the overrides folder
  133. echo/
  134. echo/
  135. choice /c YN /m "Would you like to move the overrides folder to the DOOMEternal folder?"
  136. echo/
  137. echo/
  138. if errorlevel 2 (
  139.     echo/
  140.     echo/
  141.     echo Overrides folder was created succesfully, you can find it on %scriptdir%.
  142.     echo/
  143.     echo/
  144.     goto Exit
  145. )
  146.  
  147. :: Backup previous overrides folder
  148. rmdir /s /q "%gamedir%overridesbackup"
  149. xcopy /i /s "%gamedir%overrides" "%gamedir%overridesbackup"
  150.  
  151. :: Moves overrides folder to the game folder.
  152. echo/
  153. echo/
  154. if "%replace%"=="1" (
  155.     xcopy /i /s /y "%scriptdir%overrides" "%gamedir%overrides"
  156. ) else (
  157.     xcopy /i /s "%scriptdir%overrides" "%gamedir%overrides"
  158. )
  159. rmdir /s /q "%scriptdir%overrides"
  160. echo/
  161. echo/
  162. echo The overrides folder has been created and moved successfully.
  163. echo/
  164. echo/
  165.  
  166. :: Pause to show result in console and then exit
  167. :Exit
  168. pause
  169. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement