Skip to content

Instantly share code, notes, and snippets.

@ToeKneeRED
Last active March 7, 2025 02:18
Show Gist options
  • Save ToeKneeRED/63a8867a2b6f028cab4562171e57ebfc to your computer and use it in GitHub Desktop.
Save ToeKneeRED/63a8867a2b6f028cab4562171e57ebfc to your computer and use it in GitHub Desktop.
Yeet DevelopmentAssetRegistry from a given .pak
:: REQUIRES REPAK https://github.com/trumank/repak/
:: Supply path to your desired .pak file and yeet DevelopmentAssetRegistry.bin
:: pls make sure your pak works post-use of this before deleting the previous pak
@echo off
cls
title TrimPak
set argCount=0
set argVec=
set debugMode=
set pakPath=
:HANDLE_ARGUMENTS
for %%x in (%*) do (
set /A argCount+=1
set "argVec[!argCount!]=%%~x"
if "%%~x"=="-debug" (
set "debugMode=1"
) else if not "%%~x"=="" (
set "pakPath=%%~x"
goto SKIP_PROMPT
)
)
:PAK_FILE_PATH
set /p pakPath=Enter path to .pak:
set pakPath=%pakPath:"=%
:SKIP_PROMPT
if not defined pakPath (
goto PAK_FILE_PATH
)
for %%F in ("%pakPath%") do (
set fileName=%%~nxF
set pakDirectory=%%~dpF
)
if not defined fileName (
echo Invalid .pak file.
goto PAK_FILE_PATH
)
if not defined pakDirectory (
echo Invalid directory.
goto PAK_FILE_PATH
)
:FILE_EXTENSION
for %%F in ("%fileName%") do set fileExtension=%%~xF
if not defined fileExtension (
echo Invalid .pak file, make sure there are double-quotes around the path if it has spaces: %pakDirectory%
goto PAK_FILE_PATH
)
:MOD_NAME
for /f "tokens=1,2 delims=~" %%a in ("%fileName:pakchunk=~%") do set modName=%%a
if not defined modName (
echo Failed to parse mod name.
goto PAK_FILE_PATH
)
:FOLDER_NAME
for %%F in ("%fileName%") do set folderName=%%~nF
:UNPACK
echo Unpacking %modName%...
start /B /wait repak unpack "%pakPath%"
:DEV_BIN
set devBin="%pakDirectory:"=%%folderName%\Phoenix\Mods\%modName%\Metadata\DevelopmentAssetRegistry.bin"
if exist "%devBin:"=%" (
del "%devBin:"=%"
echo Removed problem file
) else (
echo DevelopmentAssetRegistry.bin not found - may already be deleted
goto REMOVE_FOLDER
)
:REPACK
echo Repacking %modName%...
start /B /wait repak pack "%pakDirectory:"=%%folderName%"
:REMOVE_FOLDER
if exist "%pakDirectory:"=%%folderName%" (
rmdir /S /Q "%pakDirectory:"=%%folderName%"
)
:EXIT
echo Press any key to exit...
pause >nul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment