added rvz conversion
This commit is contained in:
@@ -5,15 +5,13 @@ ORANGE="#FFA500"
|
|||||||
GREY="#808080"
|
GREY="#808080"
|
||||||
|
|
||||||
# 1. Check for required tools
|
# 1. Check for required tools
|
||||||
if ! command -v gum &> /dev/null; then
|
for cmd in gum wit dolphin-tool; do
|
||||||
echo "Error: 'gum' is not installed."
|
if ! command -v $cmd &> /dev/null; then
|
||||||
|
gum style --foreground 196 "Error: '$cmd' is not installed."
|
||||||
|
[ "$cmd" == "dolphin-tool" ] && echo "Hint: Install it via your package manager (usually part of dolphin-emu)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
if ! command -v wit &> /dev/null; then
|
|
||||||
gum style --foreground "$ORANGE" "Error: 'wit' (Wiimms ISO Tools) is not installed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Aesthetic Header
|
# 2. Aesthetic Header
|
||||||
clear
|
clear
|
||||||
@@ -32,11 +30,32 @@ gum style --foreground "$GREY" " > Select the console format:"
|
|||||||
MODE=$(gum choose --cursor.foreground "$ORANGE" "Wii (WBFS)" "GameCube (ISO)")
|
MODE=$(gum choose --cursor.foreground "$ORANGE" "Wii (WBFS)" "GameCube (ISO)")
|
||||||
[ -z "$MODE" ] && exit 1
|
[ -z "$MODE" ] && exit 1
|
||||||
|
|
||||||
# 4. Source Selection
|
# 4. Source Directory & File Selection
|
||||||
gum style --foreground "$GREY" " > Select the directory containing your $MODE files"
|
gum style --foreground "$GREY" " > Step 1: Select the FOLDER containing your games"
|
||||||
ISO_DIR=$(gum file --directory)
|
ISO_DIR=$(gum file --directory)
|
||||||
[ -z "$ISO_DIR" ] && exit 1
|
[ -z "$ISO_DIR" ] && exit 1
|
||||||
|
|
||||||
|
# Move into the folder to get clean filenames
|
||||||
|
pushd "$ISO_DIR" > /dev/null
|
||||||
|
shopt -s nullglob
|
||||||
|
available_files=(*.iso *.rvz)
|
||||||
|
|
||||||
|
if [ ${#available_files[@]} -eq 0 ]; then
|
||||||
|
gum style --foreground 196 " No .iso or .rvz files found in $ISO_DIR"
|
||||||
|
popd > /dev/null
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gum style --foreground "$GREY" " > Step 2: Select the GAMES to transfer"
|
||||||
|
gum style --foreground "$GREY" " (Use SPACE to select multiple, ENTER to confirm)"
|
||||||
|
SELECTED_FILES=$(gum choose --no-limit --cursor.foreground "$ORANGE" --selected.foreground "$ORANGE" "${available_files[@]}")
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
[ -z "$SELECTED_FILES" ] && exit 1
|
||||||
|
|
||||||
|
# Read the multiline selection from Gum into a safe Bash array
|
||||||
|
mapfile -t selected_array <<< "$SELECTED_FILES"
|
||||||
|
|
||||||
# 5. USB Selection
|
# 5. USB Selection
|
||||||
USER_MEDIA="/run/media/$USER"
|
USER_MEDIA="/run/media/$USER"
|
||||||
if [ ! -d "$USER_MEDIA" ] || [ -z "$(ls -A "$USER_MEDIA" 2>/dev/null)" ]; then
|
if [ ! -d "$USER_MEDIA" ] || [ -z "$(ls -A "$USER_MEDIA" 2>/dev/null)" ]; then
|
||||||
@@ -54,8 +73,7 @@ USB_DIR="$USER_MEDIA/$SELECTED_DRIVE"
|
|||||||
|
|
||||||
# 6. Final Summary and Confirmation
|
# 6. Final Summary and Confirmation
|
||||||
clear
|
clear
|
||||||
gum style --foreground "$ORANGE" "Ready to Process $MODE"
|
gum style --foreground "$ORANGE" "Ready to Process ${#selected_array[@]} $MODE title(s)"
|
||||||
echo -e " \033[90mSource: \033[0m $ISO_DIR"
|
|
||||||
echo -e " \033[90mTarget: \033[0m $USB_DIR"
|
echo -e " \033[90mTarget: \033[0m $USB_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -63,47 +81,56 @@ gum confirm --selected.background "$ORANGE" "Begin transfer?" || exit 0
|
|||||||
|
|
||||||
# 7. Processing Loop
|
# 7. Processing Loop
|
||||||
clear
|
clear
|
||||||
gum style --foreground "$ORANGE" "Processing $MODE titles..."
|
gum style --foreground "$ORANGE" "Processing titles..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
shopt -s nullglob
|
for filename in "${selected_array[@]}"; do
|
||||||
isos=("$ISO_DIR"/*.iso)
|
full_path="$ISO_DIR/$filename"
|
||||||
|
ext="${filename##*.}"
|
||||||
|
base_name="${filename%.*}"
|
||||||
|
|
||||||
for iso_path in "${isos[@]}"; do
|
# Defaults
|
||||||
filename=$(basename "$iso_path")
|
needs_cleanup=false
|
||||||
|
working_iso="$full_path"
|
||||||
|
|
||||||
if [ "$MODE" == "Wii (WBFS)" ]; then
|
# --- RVZ UNPACKING LOGIC ---
|
||||||
# --- WII LOGIC ---
|
if [ "${ext,,}" == "rvz" ]; then
|
||||||
gum spin --spinner dot --title.foreground "$GREY" --title "Converting: $filename..." -- \
|
working_iso="$ISO_DIR/${base_name}_temp.iso"
|
||||||
wit copy "$iso_path" --wbfs --split --dest "$USB_DIR/wbfs/%T [%I]/%I.wbfs"
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
gum spin --spinner dot --title.foreground "$GREY" --title "Unpacking RVZ: $filename..." -- \
|
||||||
gum style --foreground "$ORANGE" " ✔ $filename"
|
dolphin-tool convert -i "$full_path" -o "$working_iso" -f iso
|
||||||
else
|
|
||||||
gum style --foreground 196 " ✘ Failed: $filename"
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
if [ $? -ne 0 ]; then
|
||||||
# --- GAMECUBE LOGIC ---
|
gum style --foreground 196 " ✘ Failed to unpack: $filename"
|
||||||
# 1. Get Game ID (Using tail -n 1 to avoid header/color codes)
|
|
||||||
game_id=$(wit id "$iso_path" 2>/dev/null | tail -n 1 | awk '{print $1}')
|
|
||||||
|
|
||||||
# 2. Get Title from filename and sanitize for FAT32
|
|
||||||
game_title="${filename%.*}"
|
|
||||||
clean_title=$(echo "$game_title" | tr -d ':/\\*?<>|')
|
|
||||||
|
|
||||||
# 3. Create destination path
|
|
||||||
DEST_FOLDER="$USB_DIR/games/$clean_title [$game_id]"
|
|
||||||
|
|
||||||
# Validate ID before attempting
|
|
||||||
if [[ ! "$game_id" =~ ^[A-Z0-9]{6}$ ]]; then
|
|
||||||
gum style --foreground 196 " ✘ Failed: $filename (Invalid Game ID)"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
# Flag the temporary ISO for deletion once we are done with it
|
||||||
|
needs_cleanup=true
|
||||||
|
fi
|
||||||
|
|
||||||
# 4. Perform Folder Creation and Copy with Spinner
|
# --- TRANSFER LOGIC ---
|
||||||
|
if [ "$MODE" == "Wii (WBFS)" ]; then
|
||||||
|
# WII LOGIC
|
||||||
|
gum spin --spinner dot --title.foreground "$GREY" --title "Converting to WBFS: $base_name..." -- \
|
||||||
|
wit copy "$working_iso" --wbfs --split --dest "$USB_DIR/wbfs/%T [%I]/%I.wbfs"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
gum style --foreground "$ORANGE" " ✔ $base_name"
|
||||||
|
else
|
||||||
|
gum style --foreground 196 " ✘ Failed transfer: $base_name"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
# GAMECUBE LOGIC
|
||||||
|
game_id=$(wit id "$working_iso" 2>/dev/null | tail -n 1 | awk '{print $1}')
|
||||||
|
clean_title=$(echo "$base_name" | tr -d ':/\\*?<>|')
|
||||||
|
DEST_FOLDER="$USB_DIR/games/$clean_title [$game_id]"
|
||||||
|
|
||||||
|
if [[ ! "$game_id" =~ ^[A-Z0-9]{6}$ ]]; then
|
||||||
|
gum style --foreground 196 " ✘ Failed: $base_name (Invalid Game ID)"
|
||||||
|
else
|
||||||
gum spin --spinner dot --title.foreground "$GREY" --title "Moving: $clean_title..." -- \
|
gum spin --spinner dot --title.foreground "$GREY" --title "Moving: $clean_title..." -- \
|
||||||
bash -c 'mkdir -p "$1" && cp "$2" "$1/game.iso"' _ "$DEST_FOLDER" "$iso_path"
|
bash -c 'mkdir -p "$1" && cp "$2" "$1/game.iso"' _ "$DEST_FOLDER" "$working_iso"
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
gum style --foreground "$ORANGE" " ✔ $clean_title"
|
gum style --foreground "$ORANGE" " ✔ $clean_title"
|
||||||
@@ -111,6 +138,12 @@ for iso_path in "${isos[@]}"; do
|
|||||||
gum style --foreground 196 " ✘ Failed: $clean_title"
|
gum style --foreground 196 " ✘ Failed: $clean_title"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- CLEANUP LOGIC ---
|
||||||
|
if [ "$needs_cleanup" = true ]; then
|
||||||
|
rm -f "$working_iso"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# 8. Finished
|
# 8. Finished
|
||||||
|
|||||||
Reference in New Issue
Block a user