@echo off
set CURDIR=%~dp0
cd "%curdir%"
set CURDRIVE=%curdir:~0,2%
%CURDRIVE%

set tmp_folders=no
if not {%2}=={} set tmp_folders=%2

set pkg=%1
FOR /F %%I IN ("%pkg%") DO SET pkg=%%~nxI
set pkg=%pkg:~0,-4%

if not "%pkg%"=="" echo Converting to ISO: %pkg%.cso

set iso=%1
if exist "%iso%" (goto :ISO)

if {%iso%}=={} set iso=np.cso

if not exist "%iso%" (
  dir /b "*.cso">iso.txt&&set /p iso=<"iso.txt"
  del iso.txt>nul
)

if not exist "%iso%" (goto :NoCSO)

:ISO
set ask_resign=y
set /p ask_resign=Do you want to resign the EBOOT.BIN [y/n]? [Default=YES] 
if {%ask_resign%}=={} set ask_resign=y

.\tools\ciso.exe 0 %iso% NP.ISO

if /i {%ask_resign%}=={n} goto iso2eboot
if /i {%ask_resign%}=={no} goto iso2eboot

if exist NP.ISO ("SIGN_EBOOT.bat")

:iso2eboot
if exist NP.ISO ("ISO2EBOOT.bat")
exit

:NoISO
echo ERROR: ISO not found...
pause
exit

:NoCSO
echo ERROR: CSO not found...
pause
exit
