Created
August 29, 2023 19:58
-
-
Save ankur20us/357b3692126915a0cea70cb3f66db89f to your computer and use it in GitHub Desktop.
Batch file to convert the basic iso dump of xbox game in xiso format using the extract iso program (https://github.com/XboxDev/extract-xiso)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:::::::::::::::: | |
:: 1. Keep this file at the same folder where extract-iso is present | |
:: 2. Keep the iso file in the same folder too | |
:: 3. ./run.bat | |
:: 4. Select the iso to convert | |
:::::::::::::::: | |
@echo off | |
setlocal enabledelayedexpansion | |
set "EXTRACT_XISO_COMMAND_NAME=.\extract-xiso.exe" | |
REM Count the number of ISO files | |
set "isoCount=0" | |
for %%F in (*.iso) do ( | |
set /a "isoCount+=1" | |
) | |
REM Create an array to store ISO filenames | |
set "isoFiles=" | |
set "index=1" | |
for %%F in (*.iso) do ( | |
set "isoFiles[!index!]=%%~nxF" | |
set /a "index+=1" | |
) | |
REM Display the list of ISO filenames with numbers | |
echo Number of ISO files: %isoCount% | |
echo Available ISO files: | |
for /l %%i in (1,1,%isoCount%) do ( | |
echo %%i. !isoFiles[%%i]! | |
) | |
REM Prompt the user to select a number | |
set /p "selectedNumber=Enter the number of the ISO file to process: " | |
:::::::::::::::::::::::::::::::: START INPUT CHECKING | |
set "minValue=1" | |
set "maxValue=%selectedNumber%" | |
REM if selectedNumber is not between minValue and maxValue || is not in format then exit | |
REM Check if the input is a valid number | |
for /f "delims=0123456789" %%A in ("%selectedNumber%") do ( | |
echo Invalid input. Please enter a valid number. | |
exit /b | |
) | |
REM Check if the input is within the specified range | |
if %selectedNumber% lss %minValue% ( | |
echo Input is too low. Please enter a number between %minValue% and %maxValue%. | |
exit /b | |
) else if %selectedNumber% gtr %maxValue% ( | |
echo Input is too high. Please enter a number between %minValue% and %maxValue%. | |
exit /b | |
) | |
:::::::::::::::::::::::::::::::: END INPUT CHECKING | |
REM Get the selected ISO filename from the array | |
set "selectedFileName=!isoFiles[%selectedNumber%]!" | |
REM Display the selected ISO filename | |
echo You selected: !selectedFileName! | |
set "tempName=.\!selectedNumber!.xiso" | |
REM Extracting xiso information into a temp folder | |
echo Command to be extract xiso: %EXTRACT_XISO_COMMAND_NAME% -d "!tempName!" -x ".\!selectedFileName!" | |
%EXTRACT_XISO_COMMAND_NAME% -d "!tempName!" -x ".\!selectedFileName!" | |
REM Now generating the xiso image file from temp folder | |
echo Command to be make xiso: %EXTRACT_XISO_COMMAND_NAME% -c "!tempName!" | |
%EXTRACT_XISO_COMMAND_NAME% -c "!tempName!" | |
REM Deleting the temp folder | |
echo `nDeleting temp folder being created | |
rmdir /s /q "%tempName%" | |
REM Extract just the filename (without extension) | |
for %%F in ("!selectedFileName!") do ( | |
set "selectedFileNameWithoutExtention=%%~nF" | |
) | |
set "finalFileName=!selectedFileNameWithoutExtention!.xiso.iso" | |
REM Renaming the iso file to xiso file with original filename as a reference | |
echo `nRenaming: ren "%tempName%.iso" "%selectedFileNameWithoutExtention%.xiso.iso" | |
ren "%tempName%.iso" "%selectedFileNameWithoutExtention%.xiso.iso" | |
echo `nNeed to delete original iso file %selectedFileName%? (Y/N) | |
choice /c yn | |
if "%errorlevel%"=="1" ( | |
del "%selectedFileName%" | |
echo `nFile deleted. | |
) else ( | |
echo Deletion cancelled. | |
echo Exiting. | |
) | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment