Skip to content

Instantly share code, notes, and snippets.

@sourcerebels
Created February 10, 2019 16:26
Show Gist options
  • Save sourcerebels/e20fdccd68f0485e97f24a0129aa5f7a to your computer and use it in GitHub Desktop.
Save sourcerebels/e20fdccd68f0485e97f24a0129aa5f7a to your computer and use it in GitHub Desktop.
Remove Retropie not favorite roms

Usage

It will print on standard output an script to remove all roms that are not marked as favorite in RetroPie.

python3 generate_rm_script_for_not_favorite_retropie_roms.py <system>

b.ex:

python3 generate_rm_script_for_not_favorite_retropie_roms.py snes
import sys
import os
from xml.dom import minidom
from pathlib import Path
RETROPIE_ROM_PATH = str(Path.home()) + '/RetroPie/roms'
favorite_games = 0
total_games = 0
def retrieve_system_from_arguments():
if len(sys.argv) < 2:
raise ValueError('Too little arguments')
return sys.argv[1]
def remove_rom_file(game):
path = game.getElementsByTagName('path')[0].childNodes[0].data
if not os.path.isabs(path):
path = rom_path + "/" + os.path.basename(path)
print ("rm %s" % path)
if __name__ == "__main__":
system = retrieve_system_from_arguments()
rom_path = RETROPIE_ROM_PATH + '/' + system
game_list_file = rom_path + '/gamelist.xml'
document = minidom.parse(game_list_file)
games = document.getElementsByTagName('game')
total_games = len(games)
print("system: %s" % system)
print("rom path: %s" % rom_path)
print("gamelist file: %s" % game_list_file)
print(" -------------- BEGIN SCRIPT -------------- ")
for game in games:
favorite = game.getElementsByTagName('favorite')
if favorite != None and len(favorite) > 0:
if bool(favorite[0].childNodes[0].data):
favorite_games = favorite_games + 1
remove_rom_file(game)
else:
remove_rom_file(game)
print(" -------------- END SCRIPT -------------- ")
print("total games: %d" % total_games)
print("favorite games: %d" % favorite_games)
$ python3 remove_not_favorites.py snes
system: snes
rom path: /home/pi/RetroPie/roms/snes
gamelist file: /home/pi/RetroPie/roms/snes/gamelist.xml
-------------- BEGIN SCRIPT --------------
rm /home/pi/RetroPie/roms/snes/Aerobiz (USA).smc
rm /home/pi/RetroPie/roms/snes/Bugs Bunny - Rabbit Rampage (USA).smc
rm /home/pi/RetroPie/roms/snes/Dirt Racer (Europe).smc
rm /home/pi/RetroPie/roms/snes/Donkey Kong Country (USA) (Rev 2).smc
rm /home/pi/RetroPie/roms/snes/Equinox (USA).smc
rm /home/pi/RetroPie/roms/snes/F-Zero (USA).smc
rm /home/pi/RetroPie/roms/snes/Fatal Fury (USA).smc
rm /home/pi/RetroPie/roms/snes/Fatal Fury 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Fatal Fury Special (USA).smc
rm /home/pi/RetroPie/roms/snes/Final Fantasy - Mystic Quest (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Final Fantasy II (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Final Fantasy III (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Final Fight (USA).smc
rm /home/pi/RetroPie/roms/snes/Final Fight 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Final Fight 3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Final Fight Guy (USA).smc
rm /home/pi/RetroPie/roms/snes/First Samurai (USA).smc
rm /home/pi/RetroPie/roms/snes/Flashback - The Quest for Identity (USA).smc
rm /home/pi/RetroPie/roms/snes/Ghoul Patrol (USA).smc
rm /home/pi/RetroPie/roms/snes/Gods (USA).smc
rm /home/pi/RetroPie/roms/snes/Gradius III (USA).smc
rm /home/pi/RetroPie/roms/snes/Harvest Moon (USA).smc
rm /home/pi/RetroPie/roms/snes/Humans, The (Europe).smc
rm /home/pi/RetroPie/roms/snes/Illusion of Gaia (USA).smc
rm /home/pi/RetroPie/roms/snes/Incredible Hulk, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Indiana Jones' Greatest Adventures (USA).smc
rm /home/pi/RetroPie/roms/snes/Inindo - Way of the Ninja (USA).smc
rm /home/pi/RetroPie/roms/snes/J.R.R. Tolkien's The Lord of the Rings - Volume 1 (USA).smc
rm /home/pi/RetroPie/roms/snes/Joe & Mac 2 - Lost in the Tropics (USA).smc
rm /home/pi/RetroPie/roms/snes/Jungle Strike (USA).smc
rm /home/pi/RetroPie/roms/snes/Jurassic Park (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Jurassic Park II - The Chaos Continues (USA).smc
rm /home/pi/RetroPie/roms/snes/Killer Instinct (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/King Arthur & The Knights of Justice (USA).smc
rm /home/pi/RetroPie/roms/snes/King Arthur's World (USA).smc
rm /home/pi/RetroPie/roms/snes/King of Dragons, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Kirby Super Star (USA).smc
rm /home/pi/RetroPie/roms/snes/Kirby's Avalanche (USA).smc
rm /home/pi/RetroPie/roms/snes/Kirby's Dream Course (USA).smc
rm /home/pi/RetroPie/roms/snes/Kirby's Dream Land 3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Knights of the Round (USA).smc
rm /home/pi/RetroPie/roms/snes/Lamborghini American Challenge (USA).smc
rm /home/pi/RetroPie/roms/snes/Legend (USA).smc
rm /home/pi/RetroPie/roms/snes/Legend of the Mystical Ninja, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Legend of Zelda, The - A Link to the Past (USA).smc
rm /home/pi/RetroPie/roms/snes/Lemmings (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Lufia & The Fortress of Doom (USA).smc
rm /home/pi/RetroPie/roms/snes/Lufia II - Rise of the Sinistrals (USA).smc
rm /home/pi/RetroPie/roms/snes/Magic Boy (USA).smc
rm /home/pi/RetroPie/roms/snes/Magic Sword (USA).smc
rm /home/pi/RetroPie/roms/snes/Magical Quest Starring Mickey Mouse, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Marvel Super Heroes - War of the Gems (USA).smc
rm /home/pi/RetroPie/roms/snes/MechWarrior (USA).smc
rm /home/pi/RetroPie/roms/snes/MechWarrior 3050 (USA).smc
rm /home/pi/RetroPie/roms/snes/Mega Man 7 (USA).smc
rm /home/pi/RetroPie/roms/snes/Mega Man Soccer (USA).smc
rm /home/pi/RetroPie/roms/snes/Mega Man X (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Mega Man X2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Mega Man X3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Mickey Mania - The Timeless Adventures of Mickey Mouse (USA).smc
rm /home/pi/RetroPie/roms/snes/Mickey's Playtown Adventure - A Day of Discovery! (USA) (Proto).smc
rm /home/pi/RetroPie/roms/snes/Mickey's Ultimate Challenge (USA).smc
rm /home/pi/RetroPie/roms/snes/Micro Machines (USA).smc
rm /home/pi/RetroPie/roms/snes/Micro Machines 2 - Turbo Tournament (Europe).smc
rm /home/pi/RetroPie/roms/snes/Might and Magic II - Gates to Another World (Europe).smc
rm /home/pi/RetroPie/roms/snes/Might and Magic III - Isles of Terra (USA).smc
rm /home/pi/RetroPie/roms/snes/Mortal Kombat (USA).smc
rm /home/pi/RetroPie/roms/snes/Mortal Kombat Mythologies Gold 2000 [!].smc
rm /home/pi/RetroPie/roms/snes/Mortal Kombat II (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Mortal Kombat 3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Ms. Pac-Man (USA).smc
rm /home/pi/RetroPie/roms/snes/Ninja Gaiden Trilogy (USA).smc
rm /home/pi/RetroPie/roms/snes/Ninja Warriors, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Lost Vikings 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Obitus (USA).smc
rm /home/pi/RetroPie/roms/snes/Ogre Battle - The March of the Black Queen (USA).smc
rm /home/pi/RetroPie/roms/snes/Oscar (USA).smc
rm /home/pi/RetroPie/roms/snes/Out of This World (USA).smc
rm /home/pi/RetroPie/roms/snes/Pac-Attack (USA).smc
rm /home/pi/RetroPie/roms/snes/Pac-in-Time (USA).smc
rm /home/pi/RetroPie/roms/snes/Pac-Man 2 - The New Adventures (USA).smc
rm /home/pi/RetroPie/roms/snes/Paladin's Quest (USA).smc
rm /home/pi/RetroPie/roms/snes/Paperboy 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Parodius (Europe).smc
rm /home/pi/RetroPie/roms/snes/Pilotwings (USA).smc
rm /home/pi/RetroPie/roms/snes/Pinball Dreams (USA).smc
rm /home/pi/RetroPie/roms/snes/Pinball Fantasies (USA).smc
rm /home/pi/RetroPie/roms/snes/Pit-Fighter (USA).smc
rm /home/pi/RetroPie/roms/snes/Pitfall - The Mayan Adventure (USA).smc
rm /home/pi/RetroPie/roms/snes/Pop'n TwinBee (Europe).smc
rm /home/pi/RetroPie/roms/snes/Pop'n TwinBee - Rainbow Bell Adventures (Europe).smc
rm /home/pi/RetroPie/roms/snes/Prince of Persia 2 - The Shadow & The Flame (USA).smc
rm /home/pi/RetroPie/roms/snes/Q-bert 3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Ranma 1-2 - Hard Battle (USA).smc
rm /home/pi/RetroPie/roms/snes/Rise of the Robots (USA).smc
rm /home/pi/RetroPie/roms/snes/Robotrek (USA).smc
rm /home/pi/RetroPie/roms/snes/Romance of the Three Kingdoms IV - Wall of Fire (USA).smc
rm /home/pi/RetroPie/roms/snes/Secret of Evermore (USA).smc
rm /home/pi/RetroPie/roms/snes/Secret of Mana (USA).smc
rm /home/pi/RetroPie/roms/snes/Shadow, The (USA) (Proto).smc
rm /home/pi/RetroPie/roms/snes/Skyblazer (USA).smc
rm /home/pi/RetroPie/roms/snes/Soldiers of Fortune (USA).smc
rm /home/pi/RetroPie/roms/snes/Soul Blazer (USA).smc
rm /home/pi/RetroPie/roms/snes/Spider-Man (USA).smc
rm /home/pi/RetroPie/roms/snes/Spider-Man-Venom - Maximum Carnage (USA).smc
rm /home/pi/RetroPie/roms/snes/Star Fox (USA) (Rev 2).smc
rm /home/pi/RetroPie/roms/snes/Star Fox (USA) (Super Weekend Competition).smc
rm /home/pi/RetroPie/roms/snes/Star Trek - Deep Space Nine - Crossroads of Time (USA).smc
rm /home/pi/RetroPie/roms/snes/Star Trek - Starfleet Academy - Starship Bridge Simulator (USA).smc
rm /home/pi/RetroPie/roms/snes/Star Trek - The Next Generation - Future's Past (USA).smc
rm /home/pi/RetroPie/roms/snes/Street Fighter Alpha 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Street Fighter II (USA).smc
rm /home/pi/RetroPie/roms/snes/Street Fighter II Turbo (USA).smc
rm /home/pi/RetroPie/roms/snes/Street Racer (USA).smc
rm /home/pi/RetroPie/roms/snes/Stunt Race FX (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Sunset Riders (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Adventure Island (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Adventure Island II (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Bomberman (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Bomberman 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Bomberman 3 (Europe).smc
rm /home/pi/RetroPie/roms/snes/Super Castlevania IV (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Chase H.Q. (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Double Dragon (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Ghouls'n Ghosts (USA).smc
rm /home/pi/RetroPie/roms/snes/Super James Pond (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Mario All-Stars (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Mario Kart (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Mario RPG - Legend of the Seven Stars (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Mario World (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Mario World 2 - Yoshi's Island (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Super Metroid (Japan, USA).smc
rm /home/pi/RetroPie/roms/snes/Super Ninja Boy (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Off Road (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Off Road - The Baja (USA).smc
rm /home/pi/RetroPie/roms/snes/Super R-Type (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Star Wars (USA) (Rev 1).sfc
rm /home/pi/RetroPie/roms/snes/Super Star Wars - Return of the Jedi (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Super Star Wars - The Empire Strikes Back (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Super Street Fighter II (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Turrican (USA).smc
rm /home/pi/RetroPie/roms/snes/Super Turrican 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Syndicate (USA).smc
rm /home/pi/RetroPie/roms/snes/Taz-Mania (USA) (Rev 1).sfc
rm /home/pi/RetroPie/roms/snes/Teenage Mutant Ninja Turtles - Tournament Fighters (USA).smc
rm /home/pi/RetroPie/roms/snes/Teenage Mutant Ninja Turtles IV - Turtles in Time (USA).smc
rm /home/pi/RetroPie/roms/snes/Terminator 2 - Judgment Day (USA).smc
rm /home/pi/RetroPie/roms/snes/Terminator, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Tetris & Dr. Mario (USA).smc
rm /home/pi/RetroPie/roms/snes/Tetris 2 (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Tetris Attack (USA).smc
rm /home/pi/RetroPie/roms/snes/Tiny Toon Adventures - Buster Busts Loose! (USA).smc
rm /home/pi/RetroPie/roms/snes/Tiny Toon Adventures - Wacky Sports Challenge (USA).smc
rm /home/pi/RetroPie/roms/snes/Top Gear (USA).smc
rm /home/pi/RetroPie/roms/snes/Top Gear 3000 (USA).smc
rm /home/pi/RetroPie/roms/snes/Troddlers (USA).smc
rm /home/pi/RetroPie/roms/snes/U.N. Squadron (USA).smc
rm /home/pi/RetroPie/roms/snes/Ultima - Runes of Virtue II (USA).smc
rm /home/pi/RetroPie/roms/snes/Ultima VII - The Black Gate (USA).smc
rm /home/pi/RetroPie/roms/snes/Ultraman - Towards the Future (USA).smc
rm /home/pi/RetroPie/roms/snes/Uncharted Waters (USA).smc
rm /home/pi/RetroPie/roms/snes/Warlock (USA).smc
rm /home/pi/RetroPie/roms/snes/Wing Commander (USA).smc
rm /home/pi/RetroPie/roms/snes/Wing Commander - The Secret Missions (USA).smc
rm /home/pi/RetroPie/roms/snes/Wings 2 - Aces High (USA).smc
rm /home/pi/RetroPie/roms/snes/Wizardry V - Heart of the Maelstrom (USA).smc
rm /home/pi/RetroPie/roms/snes/Wolfchild (USA).smc
rm /home/pi/RetroPie/roms/snes/Wolfenstein 3D (USA).smc
rm /home/pi/RetroPie/roms/snes/World Heroes (USA).smc
rm /home/pi/RetroPie/roms/snes/World Heroes 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Ys III - Wanderers from Ys (USA).smc
rm /home/pi/RetroPie/roms/snes/Zombies Ate My Neighbors (USA).smc
rm /home/pi/RetroPie/roms/snes/Zool - Ninja of the Nth Dimension (USA).smc
rm /home/pi/RetroPie/roms/snes/3 Ninjas Kick Back (USA).smc
rm /home/pi/RetroPie/roms/snes/7th Saga, The (USA).smc
rm /home/pi/RetroPie/roms/snes/ActRaiser (USA).smc
rm /home/pi/RetroPie/roms/snes/ActRaiser 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Addams Family, The - Pugsley's Scavenger Hunt (USA).smc
rm /home/pi/RetroPie/roms/snes/Addams Family Values (USA).smc
rm /home/pi/RetroPie/roms/snes/Addams Family, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Adventures of Batman & Robin, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Aero Fighters (USA).smc
rm /home/pi/RetroPie/roms/snes/Aero the Acro-Bat (USA).smc
rm /home/pi/RetroPie/roms/snes/Aero the Acro-Bat 2 (USA).smc
rm /home/pi/RetroPie/roms/snes/Aladdin (USA).smc
rm /home/pi/RetroPie/roms/snes/Alien 3 (USA).smc
rm /home/pi/RetroPie/roms/snes/Alien vs. Predator (USA).smc
rm /home/pi/RetroPie/roms/snes/Arcana (USA).smc
rm /home/pi/RetroPie/roms/snes/Arkanoid - Doh It Again (USA).smc
rm /home/pi/RetroPie/roms/snes/Art of Fighting (USA).smc
rm /home/pi/RetroPie/roms/snes/Asterix & Obelix (Europe).smc
rm /home/pi/RetroPie/roms/snes/Asterix (Europe).smc
rm /home/pi/RetroPie/roms/snes/Axelay (USA).smc
rm /home/pi/RetroPie/roms/snes/B.O.B. (USA).smc
rm /home/pi/RetroPie/roms/snes/Batman Forever (USA).smc
rm /home/pi/RetroPie/roms/snes/Batman Returns (USA).smc
rm /home/pi/RetroPie/roms/snes/Battletoads & Double Dragon (USA).smc
rm /home/pi/RetroPie/roms/snes/Battletoads in Battlemaniacs (USA).smc
rm /home/pi/RetroPie/roms/snes/Best of the Best - Championship Karate (USA).smc
rm /home/pi/RetroPie/roms/snes/BioMetal (USA).smc
rm /home/pi/RetroPie/roms/snes/Blackthorne (USA).smc
rm /home/pi/RetroPie/roms/snes/Blues Brothers, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Bram Stoker's Dracula (USA).smc
rm /home/pi/RetroPie/roms/snes/BreakThru! (USA).smc
rm /home/pi/RetroPie/roms/snes/Breath of Fire (USA).smc
rm /home/pi/RetroPie/roms/snes/Breath of Fire II (USA).smc
rm /home/pi/RetroPie/roms/snes/Brutal - Paws of Fury (USA).smc
rm /home/pi/RetroPie/roms/snes/Bubsy II (USA).smc
rm /home/pi/RetroPie/roms/snes/Bubsy in Claws Encounters of the Furred Kind (USA).smc
rm /home/pi/RetroPie/roms/snes/Bust-A-Move (USA).smc
rm /home/pi/RetroPie/roms/snes/California Games II (USA).smc
rm /home/pi/RetroPie/roms/snes/Cannon Fodder (Europe).smc
rm /home/pi/RetroPie/roms/snes/Captain America and the Avengers (USA).smc
rm /home/pi/RetroPie/roms/snes/Captain Commando (USA).smc
rm /home/pi/RetroPie/roms/snes/Castlevania - Dracula X (USA).smc
rm /home/pi/RetroPie/roms/snes/Choplifter III - Rescue & Survive (USA).smc
rm /home/pi/RetroPie/roms/snes/Chrono Trigger (USA).smc
rm /home/pi/RetroPie/roms/snes/Chuck Rock (USA).smc
rm /home/pi/RetroPie/roms/snes/Contra III - The Alien Wars (USA).smc
rm /home/pi/RetroPie/roms/snes/Cool Spot (USA).smc
rm /home/pi/RetroPie/roms/snes/Darius Twin (USA).smc
rm /home/pi/RetroPie/roms/snes/Death and Return of Superman, The (USA).smc
rm /home/pi/RetroPie/roms/snes/Demon's Crest (USA).smc
rm /home/pi/RetroPie/roms/snes/Desert Strike - Return to the Gulf (USA).smc
rm /home/pi/RetroPie/roms/snes/Dino Dini's Soccer! (Europe).smc
rm /home/pi/RetroPie/roms/snes/Donkey Kong Country (USA) (Competition Edition).smc
rm /home/pi/RetroPie/roms/snes/Donkey Kong Country 2 - Diddy's Kong Quest (USA) (Rev 1).smc
rm /home/pi/RetroPie/roms/snes/Donkey Kong Country 3 - Dixie Kong's Double Trouble! (USA).smc
rm /home/pi/RetroPie/roms/snes/Doom (USA).smc
rm /home/pi/RetroPie/roms/snes/Double Dragon V - The Shadow Falls (USA).smc
rm /home/pi/RetroPie/roms/snes/Dragon's Lair (USA).smc
rm /home/pi/RetroPie/roms/snes/Drakkhen (USA).smc
rm /home/pi/RetroPie/roms/snes/Dungeon Master (USA).smc
rm /home/pi/RetroPie/roms/snes/E.V.O. - Search for Eden (USA).smc
rm /home/pi/RetroPie/roms/snes/EarthBound (USA).smc
-------------- END SCRIPT --------------
total games: 235
favorite games: 62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment