RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    How can I use favourites to find the roms and move them from main folders?

    Scheduled Pinned Locked Moved Ideas and Development
    favorites
    3 Posts 2 Posters 316 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MozartsDream
      last edited by

      I am looking for a script or tool that will find all of my favourites and copy or move the roms to a destination folder. The goal is to create a collection of rom folders with only roms that have been selected as favourites. This would make it easy to take a large collection of roms, try them out, pick the ones that work, and are playable, and know that the collection is mint.

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        Assuming you're using RetroPie (and not just EmulationStation), here's a script to print the ROM files which are marked as favorites.

        #!/usr/bin/env bash
        # Assume the gamelist is properly formatted
        
        for system in $HOME/RetroPie/roms/*; do
            [ ! -d "$system" ] && continue
            short=${system##*/}
            [ -f "$system/gamelist.xml" ] && {
                xmlstarlet sel -t -m "/gameList/game[favorite='true']" \
                    -o "$system/" -v "substring-after(path, './')" -o '"' -n \
                    "$system/gamelist.xml"
                continue
            }
            [ -f "$HOME/.emulationstation/gamelists/$short/gamelist.xml" ] && {
                xmlstarlet sel -t -m "/gameList/game[favorite='true']" \
                    -o "$system/" -v "substring-after(path, './')" -o '"' -n \
                    "$HOME/.emulationstation/gamelists/$short/gamelist.xml"
            }
        done
        

        You can modify the script to copy the files to a different folder, though you'd have to account for the system (you can use the $short variable to create sub-folders at the destination folder).

        M 1 Reply Last reply Reply Quote 0
        • M
          MozartsDream @mitu
          last edited by

          @mitu
          I'm getting there:

          DEST=/media/MYDESTDRIV/favroms ; rm -rf "$DEST" ; mkdir "$DEST" ; cd /userdata/roms ; for d in * ; do [ -d "$d" ] && xmllint --xpath "/gameList/game[favorite='true']/path/text()" "${d}/gamelist.xml" 2>/dev/null | while read rom ; do echo "${d}/${rom}" && [ -e "${d}/${rom}" ] && mkdir -p "$(dirname "${DEST}/${d}/${rom}")" && cp -rp "${d}/${rom}" "${DEST}/${d}/${rom}" ; done ; done
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.