-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract.bat
More file actions
61 lines (47 loc) · 1.42 KB
/
extract.bat
File metadata and controls
61 lines (47 loc) · 1.42 KB
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
@echo off
setlocal enabledelayedexpansion enableextensions
set "log_file=extraction_log.txt"
if exist "!log_file!" del /f /q "!log_file!"
set "script_dir=%cd%"
set "par_tool=ParTool.exe"
set "par_tool_args=extract"
call :full_path staged_dir "__staged"
set /p "confirm=Do you want to make a mirrored directory hierarchy under __staged for staged changes? (Y/N) "
call :process_dir "%cd%"
goto :eof
:process_dir (
for /r "%~1" %%F in (*) do (
set "file_ext=%%~xF"
if /i "!file_ext!"==".par" (
echo %%F >> "!log_file!"
call :process_file "%%F"
)
)
exit /b
)
:process_file (
set "file_path=%~f1"
echo !file_path:%cd%=.!
set "dir_name=%~nx1"
set "output_dir=!file_path:%dir_name%=_%dir_name%!"
if exist "!output_dir!" (
set /p "confirm=!output_dir! already exists. Continuing this operation will delete the existing directory. Do you want to continue? (Y/N) "
if /i "%confirm%"=="n" (
exit /b
)
rmdir /s /q "!output_dir!"
)
set "outputm_dir=!output_dir:%cd%=%staged_dir%!"
if /i "%confirm%"=="y" (
mkdir "!outputm_dir!" 2>nul
)
"%par_tool%" %par_tool_args% "!file_path!" "!output_dir!"
exit /b
)
:full_path <resultVar> <pathVar> (
set "%~1=%~f2"
exit /b
)
:eof
echo Extraction complete. Log saved to !log_file!
endlocal