Created
September 23, 2025 18:30
-
-
Save rflpazini/7dd23f2e71263deea4c0fc42189f0ddb to your computer and use it in GitHub Desktop.
Convert script to convert ISO files to CHD. Used for PS1 and PS2 games
This file contains hidden or 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
#!/bin/bash | |
# --- Smart Recursive CHD Conversion Script (Root Output) --- | |
set -e | |
# 1. Find the script's own directory to make it runnable from anywhere. | |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
# 2. Define folders relative to the script's location. | |
# This assumes a structure where the script is in a 'scripts' folder, | |
# and the ISOs are in an 'ISO' folder. | |
# PS2/ | |
# ├── scripts/ (this script is here) | |
# └── ISO/ | |
SOURCE_FOLDER="$SCRIPT_DIR/../ISO" | |
# The output folder is now the parent directory of the script's folder. | |
OUTPUT_FOLDER="$SCRIPT_DIR/../" | |
if [ ! -d "$SOURCE_FOLDER" ]; then | |
echo "Error: Source folder not found at '$SOURCE_FOLDER' 😕" | |
exit 1 | |
fi | |
echo "Scanning for .iso files in: $SOURCE_FOLDER" | |
echo "Output will be saved to the project root folder." | |
file_count=0 | |
find "$SOURCE_FOLDER" -type f -iname "*.iso" -print0 | while IFS= read -r -d '' iso_file | |
do | |
name=$(basename "$iso_file" .iso) | |
output_file="$OUTPUT_FOLDER/$name.chd" | |
echo "---" | |
echo "Converting: $iso_file" | |
echo " ->: $output_file" | |
chdman createcd -i "$iso_file" -o "$output_file" --force | |
((file_count++)) | |
done | |
if [ "$file_count" -eq 0 ]; then | |
echo "No .iso files were found in '$SOURCE_FOLDER' or its subdirectories." | |
else | |
echo "---" | |
echo "All $file_count file(s) converted successfully! 🎉" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment