-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathprocess.cmd
More file actions
64 lines (56 loc) · 1.88 KB
/
Copy pathprocess.cmd
File metadata and controls
64 lines (56 loc) · 1.88 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
62
63
64
echo off
call :Log "Initializing..."
set EfsTools=.\utils\EfsTools\EfsTools.exe
%EfsTools% version
echo .
rem call :Log "Extracting MBNs..."
rem for /r %%f in ("*.mbn") do call :Extract %%f
call :Log "Generating modem configs..."
for /r %%f in ("*.mbn") do call :GenerateModemConfigs %%f
call :Log "Done"
pause
:Log
echo %~1
title %~1
exit /b
:Extract
setlocal ENABLEDELAYEDEXPANSION
set extractPath=%~1
set currentDir=%cd%
call :MakeRelative %extractPath% %currentDir%
set extractPath=extracted\%RETVAL%
%EfsTools% extractMbn -i "%~1" -p "%extractPath%"
exit /b
:GenerateModemConfigs
setlocal ENABLEDELAYEDEXPANSION
set extractPath=%~1
set currentDir=%cd%
call :MakeRelative %extractPath% %currentDir%
set extractedMbnPath=extracted\%RETVAL%
set jsonPath=extracted\%RETVAL%.json
%EfsTools% getModemConfig -i "%extractedMbnPath%" -p "%jsonPath%"
exit /b
:MakeRelative file base -- makes a file name relative to a base path
:: -- file [in,out] - variable with file name to be converted, or file name itself for result in stdout
:: -- base [in,opt] - base path, leave blank for current directory
:$created 20060101 :$changed 20080219 :$categories Path
:$source https://www.dostips.com
setlocal ENABLEDELAYEDEXPANSION
set src=%~1
if defined %1 set src=!%~1!
set bas=%~2
if not defined bas set bas=%cd%
for /f "tokens=*" %%a in ("%src%") do set src=%%~fa
for /f "tokens=*" %%a in ("%bas%") do set bas=%%~fa
set mat=&rem variable to store matching part of the name
set upp=&rem variable to reference a parent
for /f "tokens=*" %%a in ('echo.%bas:\=^&echo.%') do (
set sub=!sub!%%a\
call set tmp=%%src:!sub!=%%
if "!tmp!" NEQ "!src!" (set mat=!sub!)ELSE (set upp=!upp!..\)
)
set src=%upp%!src:%mat%=!
( endlocal & REM RETURN VALUES
IF defined %1 (SET %~1=%src%) ELSE (SET RETVAL=%src%)
)
exit /b