A-Vladimir

Unpacker.bat

Dec 29th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. @echo off
  2.  
  3. :: Localise environment.
  4. setlocal enableextensions enabledelayedexpansion
  5.  
  6. ::Make a variable for backspace cause $h is being a dickwad
  7. for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
  8.  
  9. :: delete all files in the directory that have the name "tmp_" in the front of them
  10. del "tmp_*.*" 2>nul
  11. ::make the temporary batch file that extracts the assets while the main window waits have
  12. ::the commands needed to extract and delete the flag file
  13. echo >>"tmp_asset_extractor.cmd" "win32\asset_unpacker.exe" "contents.pak" "Unpacked Contents"
  14. echo >>"tmp_asset_extractor.cmd" del "tmp_asset_extractor.flg"
  15. ::start the child batch file and start monitoring for the flag file's deletion
  16. call :monitor "tmp_asset_extractor.cmd" "tmp_asset_extractor.flg" 900
  17.  
  18. goto :final
  19.  
  20. :monitor
  21. :: Create flag file and start the extractor.
  22. echo >>%2 dummy file ignore this.
  23. start /min cmd.exe /c "%1"
  24.  
  25. :: Start monitoring for completion
  26. set i=0
  27. set m=%3
  28. <nul (set /p z=Waiting assets to finish extracting: ^|)
  29.  
  30. :: Loop here awaiting completion.
  31. :loop
  32. :: Wait one second.
  33. ping 127.0.0.1 -n 2 >nul
  34.  
  35. :: Update counters and output progress indicator.
  36. set /a "i = i + 1"
  37. set /a "m = m - 1"
  38. if %i% equ 4 set i=0
  39. if %i% equ 0 <nul (set /p z=%BS%^|)
  40. if %i% equ 1 <nul (set /p z=%BS%/)
  41. if %i% equ 2 <nul (set /p z=%BS%-)
  42. if %i% equ 3 <nul (set /p z=%BS%\)
  43.  
  44. :: End conditions, complete or timeout.
  45. if not exist %2 (
  46. echo.
  47. echo. Files Successfully extracted!
  48. del "tmp_*.*" 2>nul
  49. pause
  50. goto :final
  51. )
  52. if %m% leq 0 (
  53. echo.
  54. echo. *** ERROR: Timed-out waiting for extraction to finish.
  55. pause
  56. goto :final
  57. )
  58. goto :loop
  59. :final
  60. endlocal
Advertisement
Add Comment
Please, Sign In to add comment