-
Notifications
You must be signed in to change notification settings - Fork 4
/
gma_to_zip.bat
105 lines (81 loc) · 1.78 KB
/
gma_to_zip.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@echo off
set extractor=gmad.exe
set compressor=7z.exe
set addonfile=
set zipfile=
set execfile=
for %%a in (%0) do set execfile=%%~nxa
for %%a in (%1) do set addonfile=%%~dpnxa
for %%a in (%2) do set zipfile=%%~dpnxa
set addonfile="%addonfile%"
set zipfile="%zipfile%"
IF %addonfile%=="" (
echo You need to specify an addon file.
echo Useage: "%execfile% <addonfile> [<zipfile>]"
echo.
pause
@echo on
@exit /B 1
)
IF not exist %addonfile% (
echo The file %addonfile% does not exist.
echo Useage: "%execfile% <addonfile> [<zipfile>]"
echo.
pause
@echo on
@exit /B 2
)
for %%a in (%addonfile%) do set rawaddonfile=%%~dpna
for %%a in (%addonfile%) do set rawaddonfilename=%%~na
IF %zipfile%=="" (
set zipfile="%rawaddonfile%.zip"
)
set tmpfolder=%tmp%/gmatozip
set addontmp="%tmpfolder%/%rawaddonfilename%"
IF exist "%tmpfolder%" (
rmdir /s /q "%tmpfolder%" > nul
)
IF exist %zipfile% (
del /f /q %zipfile% > nul
)
echo Extracting Addon...
echo.
echo %extractor% extract -file %addonfile% -out %addontmp%
%extractor% extract -file %addonfile% -out %addontmp%
if errorlevel 1 (
echo.
echo.
echo The file %addonfile% could not be extracted.
echo Useage: "%execfile% <addonfile> [<zipfile>]"
echo.
rmdir /s /q "%tmpfolder%" > nul
pause
@echo on
@exit /B 3
)
echo.
echo.
echo.
echo.
echo Zipping addon...
echo.
echo %compressor% a -tzip -mm=BZip2 -mtc=off -mx=9 -mpass=5 -md=900000b -y %zipfile% %addontmp%
%compressor% a -tzip -mm=BZip2 -mtc=off -mx=9 -mpass=5 -md=900000b -y %zipfile% %addontmp%
if errorlevel 1 (
echo.
echo.
echo The file %zipfile% could not be created.
echo Useage: "%execfile% <addonfile> [<zipfile>]"
echo.
rmdir /s /q "%tmpfolder%" > nul
pause
@echo on
@exit /B 4
)
rmdir /s /q "%tmpfolder%" > nul
echo.
echo.
echo.
echo.
@echo on
@exit /B 0