-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSARC_LIST.BAT
87 lines (67 loc) · 1.89 KB
/
PSARC_LIST.BAT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@echo]************************************************************
@echo]*
@echo]* %~nx0
@echo]*
@echo]* Drag-n-drop one or more pak files or folders containing pak files onto
@echo]* this script. A list of archived files for each pak will be dumped
@echo]* to a pak_list.txt file in the same directory.
@echo]*
@echo]************************************************************
@echo]
@echo off
setlocal
REM -------------------------------------------------------------
REM INITIALIZE
set PSARC="%~dp0\bin\psarc.exe"
REM -------------------------------------------------------------
REM EXECUTE
REM NOTHING TO DO?
if "%~1"=="" goto EOF
REM MAIN LOOP
:NEXT
if "%~1"=="" goto EOF
call :VALIDATE_PATH_EXISTS %1 || goto EOF
call :DETECT_FOLDER %1 && call :LIST_FOLDER %1 || call :LIST_FILE %1
shift & goto NEXT
SANITY CHECK: This should never be reached!
REM -------------------------------------------------------------
REM FUNCTIONS
REM returns 0 (success) or 1 (fail)
:VALIDATE_PATH_EXISTS
if not exist %1 call :ERROR %1 does not exist! & exit /b 1
exit /b 0
REM Detects if %1 is a directory or a file.
REM returns 0 (folder) or 1 (file)
:DETECT_FOLDER
setlocal
set attr=%~a1
set attr=%attr:~0,1%
set attr=%attr:-=%
if not defined attr exit /b 1
exit /b 0
:LIST_FILE
pushd "%~dp1"
set PAK=%~nx1
set PAK_LIST=%~n1.pak_list.txt
echo %PAK%
%PSARC% list "%PAK%" > "%PAK_LIST%"
echo Created "%PAK_LIST%" & goto DONE
:LIST_FOLDER
pushd "%~1"
set PAK_LIST=../%~n1.pak_list.txt
if exist "%PAK_LIST%" del /q "%PAK_LIST%"
for %%I in ("*.pak") do (
echo %%~nxI
%PSARC% list "%%~nxI" >> "%PAK_LIST%
echo] >> "%PAK_LIST%"
)
if not exist "%PAK_LIST%" (
call :ERROR "%SRC%" does not contain any pak files. & goto DONE
)
echo Created "%PAK_LIST%"
goto DONE
:ERROR
echo %* & echo] & pause & exit /b
:DONE
popd & exit /b
:EOF