@ECHO OFF
if "%~1"=="" goto :usage
set path_exe=%~d0%~p0
set path_arg=%~d1%~p1
cd /D %path_arg%
"%path_exe%imgfs\dumpxip.exe" "%~1"
if not "%errorlevel%"=="0" goto :mstools
goto :EOF
:usage
echo Usage:
echo dumpxip.bat ^<.nb.payload^>
pause
goto :EOF
:mstools
REM Try if msflshtool will extract a xip
REM on A701 it's part1
"%path_exe%imgfs\osnbtool.exe" "%~1" -d -p 1
REM Rename file to xip.bin
ren "%~1".part1 xip.bin
REM and run dumpxip again
"%path_exe%imgfs\dumpxip.exe" xip.bin
if not "%errorlevel%"=="0" goto :error
goto :EOF
 
:error
echo.
echo ERROR! (errorlevel: %errorlevel%)
pause