Created
November 2, 2024 13:11
-
-
Save peterjaap/16c54977d4bb21c382e3c0c4bfcdb6b6 to your computer and use it in GitHub Desktop.
Script to clean Miyoo games list - remove 99% of all games
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
#!/bin/bash | |
# Define the backup directory | |
BACKUP_DIR=~/backup-miyoo-games | |
SOURCE_DIR="/mnt/sd-card/Roms" | |
# Create the backup directory if it doesn't exist | |
mkdir -p "$BACKUP_DIR" | |
WELL_KNOWN_GAMES=( | |
# NES Classics | |
"/mnt/sd-card/Roms/FC/Super Mario Bros.nes" | |
"/mnt/sd-card/Roms/FC/Legend of Zelda.nes" | |
"/mnt/sd-card/Roms/FC/Metroid.nes" | |
"/mnt/sd-card/Roms/FC/Castlevania.nes" | |
"/mnt/sd-card/Roms/FC/Mega Man 2.nes" | |
"/mnt/sd-card/Roms/FC/Kid Icarus.nes" | |
"/mnt/sd-card/Roms/FC/Excitebike.nes" | |
"/mnt/sd-card/Roms/FC/Contra.nes" | |
"/mnt/sd-card/Roms/FC/Final Fantasy.nes" | |
"/mnt/sd-card/Roms/FC/Bubble Bobble.nes" | |
"/mnt/sd-card/Roms/FC/Dr. Mario.nes" | |
"/mnt/sd-card/Roms/FC/Duck Hunt.nes" | |
"/mnt/sd-card/Roms/FC/Ninja Gaiden.nes" | |
"/mnt/sd-card/Roms/FC/Double Dragon II.nes" | |
"/mnt/sd-card/Roms/FC/Adventure Island.nes" | |
"/mnt/sd-card/Roms/FC/Punch-Out!!.nes" | |
"/mnt/sd-card/Roms/FC/Blaster Master.nes" | |
"/mnt/sd-card/Roms/FC/Battletoads.nes" | |
"/mnt/sd-card/Roms/FC/Bionic Commando.nes" | |
"/mnt/sd-card/Roms/FC/Kirby’s Adventure.nes" | |
# SNES Classics | |
"/mnt/sd-card/Roms/SFC/Super Mario World.smc" | |
"/mnt/sd-card/Roms/SFC/The Legend of Zelda - A Link to the Past.smc" | |
"/mnt/sd-card/Roms/SFC/Chrono Trigger.smc" | |
"/mnt/sd-card/Roms/SFC/Final Fantasy III.smc" | |
"/mnt/sd-card/Roms/SFC/Donkey Kong Country.smc" | |
"/mnt/sd-card/Roms/SFC/Super Metroid.smc" | |
"/mnt/sd-card/Roms/SFC/Street Fighter II Turbo.smc" | |
"/mnt/sd-card/Roms/SFC/Super Mario Kart.smc" | |
"/mnt/sd-card/Roms/SFC/Tetris and Dr. Mario.zip" | |
"/mnt/sd-card/Roms/SFC/Secret of Mana.smc" | |
"/mnt/sd-card/Roms/SFC/Yoshi’s Island.smc" | |
"/mnt/sd-card/Roms/SFC/Super Castlevania IV.smc" | |
"/mnt/sd-card/Roms/SFC/Mega Man X.smc" | |
"/mnt/sd-card/Roms/SFC/F-Zero.smc" | |
"/mnt/sd-card/Roms/SFC/Star Fox.smc" | |
"/mnt/sd-card/Roms/SFC/Donkey Kong Country 2.smc" | |
"/mnt/sd-card/Roms/SFC/Super Ghouls 'n Ghosts.smc" | |
"/mnt/sd-card/Roms/SFC/EarthBound.smc" | |
"/mnt/sd-card/Roms/SFC/Breath of Fire.smc" | |
"/mnt/sd-card/Roms/SFC/Illusion of Gaia.smc" | |
# Genesis Classics | |
"/mnt/sd-card/Roms/MD/Sonic the Hedgehog.bin" | |
"/mnt/sd-card/Roms/MD/Streets of Rage 2.bin" | |
"/mnt/sd-card/Roms/MD/Gunstar Heroes.bin" | |
"/mnt/sd-card/Roms/MD/Altered Beast.bin" | |
"/mnt/sd-card/Roms/MD/Earthworm Jim.bin" | |
"/mnt/sd-card/Roms/MD/Mortal Kombat.bin" | |
"/mnt/sd-card/Roms/MD/Golden Axe.bin" | |
"/mnt/sd-card/Roms/MD/Ristar.bin" | |
"/mnt/sd-card/Roms/MD/Phantasy Star IV.bin" | |
"/mnt/sd-card/Roms/MD/Comix Zone.bin" | |
"/mnt/sd-card/Roms/MD/Shining Force II.bin" | |
"/mnt/sd-card/Roms/MD/VectorMan.bin" | |
"/mnt/sd-card/Roms/MD/Shadow Dancer.bin" | |
"/mnt/sd-card/Roms/MD/Castlevania - Bloodlines.bin" | |
"/mnt/sd-card/Roms/MD/Ecco the Dolphin.bin" | |
"/mnt/sd-card/Roms/MD/Sonic & Knuckles.bin" | |
"/mnt/sd-card/Roms/MD/Aladdin.bin" | |
"/mnt/sd-card/Roms/MD/TMNT - The Hyperstone Heist.bin" | |
"/mnt/sd-card/Roms/MD/Road Rash II.bin" | |
"/mnt/sd-card/Roms/MD/Landstalker.bin" | |
# Game Boy Advance Classics | |
"/mnt/sd-card/Roms/GBA/Pokemon Fire Red.gba" | |
"/mnt/sd-card/Roms/GBA/Legend of Zelda - Minish Cap.gba" | |
"/mnt/sd-card/Roms/GBA/Super Mario Advance.gba" | |
"/mnt/sd-card/Roms/GBA/Metroid Fusion.gba" | |
"/mnt/sd-card/Roms/GBA/Golden Sun.gba" | |
"/mnt/sd-card/Roms/GBA/Yoshi's Island - Super Mario Advance 3.gba" | |
"/mnt/sd-card/Roms/GBA/Kirby - Nightmare in Dreamland.gba" | |
"/mnt/sd-card/Roms/GBA/Advance Wars.gba" | |
"/mnt/sd-card/Roms/GBA/Final Fantasy Tactics Advance.gba" | |
"/mnt/sd-card/Roms/GBA/Fire Emblem.gba" | |
"/mnt/sd-card/Roms/GBA/Metroid Zero Mission.gba" | |
"/mnt/sd-card/Roms/GBA/Mario Kart - Super Circuit.gba" | |
"/mnt/sd-card/Roms/GBA/Sonic Advance.gba" | |
"/mnt/sd-card/Roms/GBA/Legend of Zelda - A Link to the Past.gba" | |
"/mnt/sd-card/Roms/GBA/Breath of Fire II.gba" | |
"/mnt/sd-card/Roms/GBA/WarioWare Inc..gba" | |
"/mnt/sd-card/Roms/GBA/Harvest Moon - Friends of Mineral Town.gba" | |
"/mnt/sd-card/Roms/GBA/Sword of Mana.gba" | |
"/mnt/sd-card/Roms/GBA/Mother 3.gba" | |
"/mnt/sd-card/Roms/GBA/Klonoa - Empire of Dreams.gba" | |
# Arcade Classics | |
"/mnt/sd-card/Roms/ARCADE/aliencha.zip" | |
"/mnt/sd-card/Roms/ARCADE/altbeast.zip" | |
"/mnt/sd-card/Roms/ARCADE/tetris.zip" | |
"/mnt/sd-card/Roms/ARCADE/puzzleBobble.zip" | |
"/mnt/sd-card/Roms/ARCADE/metalSlug.zip" | |
"/mnt/sd-card/Roms/ARCADE/sf2.zip" | |
"/mnt/sd-card/Roms/ARCADE/ffight.zip" | |
"/mnt/sd-card/Roms/ARCADE/dino.zip" | |
"/mnt/sd-card/Roms/ARCADE/rampage.zip" | |
"/mnt/sd-card/Roms/ARCADE/ghouls.zip" | |
"/mnt/sd-card/Roms/ARCADE/bubblebobble.zip" | |
"/mnt/sd-card/Roms/ARCADE/commando.zip" | |
"/mnt/sd-card/Roms/ARCADE/neogeo.zip" | |
"/mnt/sd-card/Roms/ARCADE/raiden.zip" | |
"/mnt/sd-card/Roms/ARCADE/contra.zip" | |
"/mnt/sd-card/Roms/ARCADE/snowbros.zip" | |
"/mnt/sd-card/Roms/ARCADE/knights.zip" | |
"/mnt/sd-card/Roms/ARCADE/willow.zip" | |
"/mnt/sd-card/Roms/ARCADE/sunset.zip" | |
"/mnt/sd-card/Roms/ARCADE/strider.zip" | |
) | |
# Function to check if a game is well known | |
is_well_known() { | |
local game="$1" | |
for known in "${WELL_KNOWN_GAMES[@]}"; do | |
if [[ "$game" == "$known" ]]; then | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
# Find and process ROM files with the specified extensions | |
find "$SOURCE_DIR" -type f \( \ | |
-name "*.nes" -o \ | |
-name "*.smc" -o \ | |
-name "*.bin" -o \ | |
-name "*.gba" -o \ | |
-name "*.zip" \ | |
\) | while read -r file; do | |
if ! is_well_known "$file"; then | |
# Create the backup path | |
backup_path="$BACKUP_DIR${file#$SOURCE_DIR}" | |
mkdir -p "$(dirname "$backup_path")" | |
# Move the file to the backup location | |
mv "$file" "$backup_path" | |
echo "Moved $file to $backup_path" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment