-
-
Save Cyphs/adbee4788b4649d2587977cd402aef06 to your computer and use it in GitHub Desktop.
Yeet DevelopmentAssetRegistry.bin from a single .pak file or a directory for bulk processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: REQUIRES REPAK https://github.com/trumank/repak/ | |
:: Process a single .pak file or all .pak files in a directory | |
@echo off | |
setlocal enabledelayedexpansion | |
cls | |
title TrimPak | |
echo Select an option: | |
echo 1. Process a single .pak file | |
echo 2. Process all .pak files in a directory (Bulk) | |
set /p "choice=Enter your choice (1 or 2): " | |
if "%choice%"=="1" goto :PROCESS_SINGLE | |
if "%choice%"=="2" goto :PROCESS_BULK | |
echo Invalid choice. Exiting... | |
goto EXIT | |
:PROCESS_SINGLE | |
set "pakPath=" | |
set /p "pakPath=Enter path to .pak file: " | |
set "pakPath=%pakPath:"=%" | |
if not exist "%pakPath%" ( | |
echo Invalid file path. | |
goto EXIT | |
) | |
for %%I in ("%pakPath%") do ( | |
set "fileName=%%~nxI" | |
set "pakDirectory=%%~dpI" | |
set "modName=%%~nI" | |
) | |
set "modIndex=1" | |
set "modCount=1" | |
set "logFile=TrimPak.log" | |
echo Processing started at %date% %time% > "%logFile%" | |
echo Pak file: %pakPath% >> "%logFile%" | |
call :ProcessMod "%pakPath%" "%fileName%" "%pakDirectory%" "%modName%" "%modIndex%" "%modCount%" | |
goto DONE_PROCESSING_SINGLE | |
:PROCESS_BULK | |
set "modRootPath=" | |
set /p "modRootPath=Enter path to folder: " | |
set "modRootPath=%modRootPath:"=%" | |
if not exist "%modRootPath%" ( | |
echo Invalid directory. | |
goto EXIT | |
) | |
set "logFile=TrimPakBulk.log" | |
echo Processing started at %date% %time% > "%logFile%" | |
echo Root directory: %modRootPath% >> "%logFile%" | |
echo Detecting mods... | |
set "modCount=0" | |
if exist modsList.txt del modsList.txt | |
for /r "%modRootPath%" %%F in ("*pakchunk0-WindowsNoEditor.pak") do ( | |
if exist "%%F" ( | |
set /A modCount+=1 | |
echo Detected pak file: %%F | |
echo %%F >> modsList.txt | |
) | |
) | |
if %modCount%==0 ( | |
echo No mods found in the specified directory. | |
echo No mods found in the specified directory. >> "%logFile%" | |
goto EXIT | |
) | |
echo %modCount% mods detected. | |
echo %modCount% mods detected. >> "%logFile%" | |
set /p "proceed=Do you wish to proceed with processing? (y/n): " | |
if /I "%proceed%" neq "y" goto EXIT | |
set "modIndex=0" | |
for /F "delims=" %%F in (modsList.txt) do ( | |
set /A modIndex+=1 | |
set "pakPath=%%F" | |
set "fileName=%%~nxF" | |
set "pakDirectory=%%~dpF" | |
call :ProcessMod "!pakPath!" "!fileName!" "!pakDirectory!" "!modIndex!" "%modCount%" | |
) | |
goto DONE_PROCESSING_BULK | |
:ProcessMod | |
setlocal | |
set "pakPath=%~1" | |
set "fileName=%~2" | |
set "pakDirectory=%~3" | |
set "modIndex=%~4" | |
set "modCount=%~5" | |
echo Processing mod "%fileName%" (%modIndex%/%modCount%) | |
echo Pak path: "%pakPath%" | |
echo Processing mod "%fileName%" (%modIndex%/%modCount%) >> "%logFile%" | |
echo Pak path: "%pakPath%" >> "%logFile%" | |
for /f "tokens=1,2 delims=~" %%a in ("%fileName:pakchunk=~%") do set "modName=%%a" | |
for %%N in ("%fileName%") do set "folderName=%%~nN" | |
echo Unpacking "%modName%"... | |
echo Unpacking "%modName%" >> "%logFile%" | |
call repak unpack "%pakPath%" | |
if errorlevel 1 ( | |
echo Failed to unpack "%pakPath%". | |
echo Failed to unpack "%pakPath%". >> "%logFile%" | |
set /p "continue=Continue processing other mods? (y/n): " | |
if /I "%continue%" neq "y" goto EXIT | |
goto :EOF | |
) | |
set "devBin=%pakDirectory%%folderName%\Phoenix\Mods\%modName%\Metadata\DevelopmentAssetRegistry.bin" | |
if exist "%devBin%" ( | |
del "%devBin%" | |
echo Removed problem file | |
echo Removed DevelopmentAssetRegistry.bin from %devBin% >> "%logFile%" | |
) else ( | |
echo DevelopmentAssetRegistry.bin not found - may already be deleted | |
echo DevelopmentAssetRegistry.bin not found - may already be deleted >> "%logFile%" | |
) | |
echo Repacking "%modName%"... | |
echo Repacking "%modName%" >> "%logFile%" | |
call repak pack "%pakDirectory%%folderName%" | |
if errorlevel 1 ( | |
echo Failed to repack "%pakPath%". | |
echo Failed to repack "%pakPath%". >> "%logFile%" | |
set /p "continue=Continue processing other mods? (y/n): " | |
if /I "%continue%" neq "y" goto EXIT | |
goto :EOF | |
) | |
if exist "%pakDirectory%%folderName%" ( | |
rmdir /S /Q "%pakDirectory%%folderName%" | |
echo Removed unpacked folder "%pakDirectory%%folderName%" >> "%logFile%" | |
) | |
echo Successfully processed "%modName%". | |
echo Successfully processed "%modName%". >> "%logFile%" | |
endlocal | |
goto :EOF | |
:DONE_PROCESSING_SINGLE | |
echo Processing completed. | |
goto EXIT | |
:DONE_PROCESSING_BULK | |
echo Processing completed at %date% %time% >> "%logFile%" | |
echo Processing completed. | |
goto EXIT | |
:EXIT | |
if exist modsList.txt del modsList.txt | |
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
TrimPak.mp4
Note: This is just an example to demonstrate how Bulk processing works. If you want to actually use it to trim your mod list properly, read the Notes in the above comment.