-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract.cmd
96 lines (88 loc) · 1.96 KB
/
extract.cmd
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
@echo off
setlocal enableextensions enabledelayedexpansion
:init-param
set compress=compress
set bindir=%~dp0\bin
set codebook=packed_codebooks_aoTuV_603.bin
set input=.
set output=.\output
set tempdir=%temp%\tmp%random%
if "%~1" neq "" (
set input=%~1
)
if "%~2" neq "" (
set output=%~2
)
:check-env
echo ===== Genshin Impact Audio Extractor =====
echo.
where /q java || (
echo Error: Cannot find Java in environment.
pause
exit /b 2
)
:check-param
if not exist "%input%" (
echo Error: Input does not exist.
pause
exit /b 1
)
if not exist "%output%" (
md "%output%" || (
pause
exit /b 2
)
) else if not exist "%output%\*" (
echo Error: Output is not a directory.
pause
exit /b 1
)
md "%tempdir%" || (
echo Error: Cannot create temp directory.
pause
exit /b 2
)
:process
"%bindir%\quickbms.exe" -F {}.pck "%bindir%\wavescan.bms" "%input%" "%tempdir%" || (
rd /s /q "%tempdir%"
pause
exit /b 2
)
echo.
for %%f in ("%tempdir%\*.wav") do (
echo Processing "%%~nxf"...
java -jar "%bindir%\ptadpcminflate.jar" "%%f" "%output%\%%~nf.wav"
if !errorlevel! equ 0 (
del "%%f"
if "%compress%" equ "compress" (
"%bindir%\flac\flac.exe" "%output%\%%~nf.wav" -o "%output%\%%~nf.flac" && (
del "%output%\%%~nf.wav"
) || echo Warning: Failed to encode "%output%\%%~nf.wav" to FLAC.
)
echo.
) else if !errorlevel! equ 1 (
echo Passing to ww2ogg to handle...
echo.
"%bindir%\ww2ogg\ww2ogg.exe" "%%f" -o "%%~dpnf.ogg" --pcb "%bindir%\ww2ogg\%codebook%" && (
"%bindir%\revorb.exe" "%%~dpnf.ogg" "%output%\%%~nf.ogg" && (
del "%%f" "%%~dpnf.ogg"
)
) || echo Warning: Failed to convert "%%f" to OGG.
echo.
) else (
del "%output%\%%~nf.wav" 2>nul
echo Warning: Failed to parse "%%f".
echo.
)
)
:cleanup
if exist "%tempdir%\*.wav" (
if not exist "%output%\bad\*" (
md "%output%\bad" 2>nul
)
move /y "%tempdir%\*.wav" "%output%\bad"
echo Failed to process some files. Moved to "%output%\bad".
)
rd /s /q "%tempdir%"
echo Extraction completed.
pause