Skip to content

Instantly share code, notes, and snippets.

@ThisIsAreku
Created June 29, 2014 16:40
Show Gist options
  • Select an option

  • Save ThisIsAreku/2b47278d85e6f4645d68 to your computer and use it in GitHub Desktop.

Select an option

Save ThisIsAreku/2b47278d85e6f4645d68 to your computer and use it in GitHub Desktop.
wbfs add file (wbfs or iso) and convert to iso
@echo off
Setlocal EnableDelayedExpansion
cd %~dp0
SET output=wbfs
SET tool=wbfs_file.exe
REM -- Safeguard --
SET info_file=-
SET game_id=-
SET game_name=-
REM -- testing for tool
IF NOT EXIST "%tool%" (
echo tool %tool% not found !
GOTO END
)
REM -- checking output
IF NOT EXIST "%output%" mkdir "%output%" > NUL
echo Processing file %~nx1
REM -- checking file type
IF /i "%~x1" == ".wbfs" GOTO COPY_WBFS
IF /i "%~x1" == ".iso" GOTO CONVERT_ISO
echo Bad file extension (iso / wbfs only)
GOTO END
:CONVERT_ISO
echo Converting ISO
%tool% -4 -x 1 %1 convert %output%
GOTO END
:COPY_WBFS
echo Copying WBFS
%tool% -4 -x 1 %1 make_info > NUL
FOR %%G IN (*.txt) DO SET info_file=%%G
IF "%info_file" == "-" GOTO UERR
FOR /F "tokens=1" %%G IN (%info_file%) DO SET game_id=%%G
IF "%game_id" == "-" GOTO UERR
FOR /F "tokens=2* delims=^=" %%G in (%info_file%) DO SET game_name=%%G
IF "%game_name" == "-" GOTO UERR
REM -- format game_name (remove first space)
SET game_name=%game_name:~1%
SET game_path=%output%\%game_name% [%game_id%]
echo Adding %game_name% (%game_id%) in %game_path%
IF EXIST "%game_path%" (
echo %game_path% already exists
SET /P ANSWER="Do you want to continue (Y/N)? "
IF /i "%ANSWER%"=="n" GOTO END
IF /i "%ANSWER%"=="no" GOTO END
) ELSE mkdir "%game_path%"
echo Copying files...
move /Y %info_file% "%game_path%" > NUL
copy /Y /Z %1 "%game_path%"
GOTO END
:UERR
echo Unexpected error
:END
IF NOT "%info_file%" == "-" DEL /F "%info_file%" > NUL
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment