@echo off
rem PAK FILE RENAMER, v 1.00
rem by Mike Chu, for use with the M&P HLS
rem Cannot be used through Windows Explorer, unfortunately.. because of working directory
rem problems..

:TITLE
echo.
echo Pak File Renamer, v 1.00
echo ========================

if "%1a"=="a" goto HELP
if not exist %1 goto FILE_NOT_FOUND

:MAIN
rem Rename the file to the first available pakX.pak name.
rem FIRST, check to make sure we have enough space in the env
set EXT=99
if not %EXT%==99 goto NO_MEMORY

if not exist pak20.pak set EXT=20
if not exist pak19.pak set EXT=19
if not exist pak18.pak set EXT=18
if not exist pak17.pak set EXT=17
if not exist pak16.pak set EXT=16
if not exist pak15.pak set EXT=15
if not exist pak14.pak set EXT=14
if not exist pak13.pak set EXT=13
if not exist pak12.pak set EXT=12
if not exist pak11.pak set EXT=11
if not exist pak10.pak set EXT=10
if not exist pak9.pak set EXT=9
if not exist pak8.pak set EXT=8
if not exist pak7.pak set EXT=7
if not exist pak6.pak set EXT=6
if not exist pak5.pak set EXT=5
if not exist pak4.pak set EXT=4
if not exist pak3.pak set EXT=3
if not exist pak2.pak set EXT=2
if not exist pak1.pak set EXT=1
if not exist pak0.pak set EXT=0

if %EXT%==99 goto NO_NAMES_AVAILABLE
echo Renaming %1 to pak%EXT%.pak
ren %1 pak%EXT%.pak
if exist pak%EXT%.pak echo Renaming SUCCESSFUL!
if not exist pak%EXT%.pak echo Renaming was NOT SUCCESSFUL!  =(
goto END



:FILE_NOT_FOUND
echo %0 : File "%1" not found
echo.
goto HELP


:HELP
echo The purpose of this batch file is to take a recently unzipped M&P HLS pak file
echo and rename it to match Half-Life's naming convention for pak files.  Currently
echo it can echo rename up to 20 different files.  If more names are required (for
echo additional pak files) I will write a new batch file to handle them.
echo (This is a very simple batch file.  If someone has a better method, please let
echo me know:  michaelgchu@hotmail.com)
goto END


:NO_MEMORY
echo %0 : not enough environmental memory.  Please increase the environment
echo size and then run again.
echo.
echo (
echo  I haven't tested it, but you might want to try this command:
echo	command /e:4096 /c %0 %1
echo )
goto END


:NO_NAMES_AVAILABLE
echo %0 : no pakX.pak names are available from 1 -> 20.  You must rename
echo the pak file manually (i.e. yourself).
goto END


:END
echo.
