RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    How can I create a "list of games" - Just the titles only?

    Scheduled Pinned Locked Moved Help and Support
    gamelistorganizationemustation
    18 Posts 3 Posters 2.0k 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.
    • TPRT
      TPR
      last edited by

      While I know all the data exists in the gamelist.xml is there an easy way to extract just the list of games? Like for example if I'm making an excel spreadsheet of all the games I have on my Pi and I just want a list of only the game names?

      Has anyone written a tool that does that or is there an easy way to get just the game name data from the gamelist.xml?

      Thank you.

      mituM 1 Reply Last reply Reply Quote 0
      • TPRT
        TPR
        last edited by

        While I know all the data exists in the gamelist.xml is there an easy way to extract just the list of games? Like for example if I'm making an excel spreadsheet of all the games I have on my Pi and I just want a list of only the game names?

        Has anyone written a tool that does that or is there an easy way to get just the game name data from the gamelist.xml?

        Thank you.

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

          I did a excel export script a while ago - https://retropie.org.uk/forum/topic/16319/.
          If you just want the names, you can run

          grep '<name>' ~/.emulationstation/gamelists/*/*.xml
          

          and get the output, removing the XML tags.

          TPRT 4 Replies Last reply Reply Quote 2
          • ClydeC
            Clyde
            last edited by Clyde

            Two years ago, I posted a way of getting a sorted list of games with only a few console commands:

            https://retropie.org.uk/forum/post/168219

            edit: And then as now, @mitu and I post our respective solutions in direct succession. 😁

            1 Reply Last reply Reply Quote 3
            • TPRT
              TPR @mitu
              last edited by

              @mitu @Clyde Fantastic! Thank you to both of you!

              1 Reply Last reply Reply Quote 0
              • TPRT
                TPR @mitu
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • TPRT
                  TPR @mitu
                  last edited by

                  @mitu I'm getting an error: "repository not found" when doing this step from the link you posted:
                  git clone --depth=1 https://github.com/jmcnamara/xlsxwriter

                  TPRT 1 Reply Last reply Reply Quote 0
                  • TPRT
                    TPR @TPR
                    last edited by

                    @mitu not found.jpg

                    TPRT 1 Reply Last reply Reply Quote 0
                    • TPRT
                      TPR @TPR
                      last edited by

                      @mitu nevermind I just saw my typo. My brain was still thinking of the "old version" of excel!

                      1 Reply Last reply Reply Quote 0
                      • TPRT
                        TPR @mitu
                        last edited by TPR

                        @mitu said in How can I create a "list of games" - Just the titles only?:

                        grep '<name>' ~/.emulationstation/gamelists//.xml

                        I keep getting the following error running the python script:
                        error.jpg

                        Honestly, is there any way to output the data from the following command to a file instead of to the screen?
                        grep '<name>' ~/.emulationstation/gamelists//.xml

                        TPRT mituM 2 Replies Last reply Reply Quote 0
                        • TPRT
                          TPR @TPR
                          last edited by TPR

                          I found it!
                          grep '<name>' ~/.emulationstation/gamelists//.xml > outputfile.txt

                          That actually works great for me!

                          Thanks again for all your help!

                          ClydeC 1 Reply Last reply Reply Quote 1
                          • mituM
                            mitu Global Moderator @TPR
                            last edited by

                            @tpr said in How can I create a "list of games" - Just the titles only?:

                            Honestly, is there any way to output the data from the following command to a file instead of to the screen?

                            Looks like one of your gamelists is malformed, if you run the script with the -d switch, it will tell you which system has the issue.

                            TPRT 1 Reply Last reply Reply Quote 0
                            • TPRT
                              TPR @mitu
                              last edited by

                              @mitu Thanks!

                              1 Reply Last reply Reply Quote 0
                              • ClydeC
                                Clyde @TPR
                                last edited by Clyde

                                @tpr said in How can I create a "list of games" - Just the titles only?:

                                I found it!
                                grep '<name>' ~/.emulationstation/gamelists//.xml > outputfile.txt

                                Very good, I like it when people work out their own solutions. 👍

                                In addition, you could "pipe" the output through the command sort to get a sorted list, as the gamelist.xml isn't sorted per se, and can become disordered after new games are added or if you scrape them multiple times with scrapers that append to the gamelist.xml instead of recreating it completely.

                                grep '<name>' ~/.emulationstation/gamelists/*/*.xml | sort > outputfile.txt
                                

                                Mind though that the above command will "walk" through any directory in ~/.emulationstation/gamelists/ and every xml file within them, and display all of their game names. So, if you have multiple systems and/or xml files within them (e.g. backups like gamelist-backup.xml), you might want to change */*.xml to the exact gamelist in question, e.g.

                                grep '<name>' ~/.emulationstation/gamelists/arcade/gamelist.xml | sort > outputfile.txt
                                

                                And finally, if you want an output without the <name> tags, use my solution with xmlstarlet. Its only (tiny) drawback is that it has to be installed first, whereas grep comes pre-installed in any Linux system that I know of.

                                As always, there are multiple ways to solve single problems. 🤓

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

                                  @clyde said in How can I create a "list of games" - Just the titles only?:

                                  Its only (tiny) drawback is that it has to be installed first, whereas grep comes pre-installed in any Linux system that I know of.

                                  xmlstarlet is automatically installed by RetroPie, so it should always be available.

                                  ClydeC TPRT 2 Replies Last reply Reply Quote 1
                                  • ClydeC
                                    Clyde @mitu
                                    last edited by

                                    @mitu Interesting, I thought I had to install it back then (or whenever I installed RP 4.6). But one tends to forget such one-time installs, so … 😉

                                    1 Reply Last reply Reply Quote 0
                                    • TPRT
                                      TPR @mitu
                                      last edited by TPR

                                      @mitu So coming back to this topic I had another question...

                                      While the grep command actually works great and I get ALMOST exactly what I need from that, the one issue is still is there is anything in my gamelist that ended being deleted or edited and didn't get removed from the gamelist, that data is still output in the .txt file that grep generates.

                                      What I'm looking for is a text output of exactly the same list I see on my screen. Clearly, Emulation Station must pull the data from somewhere to display it on my screen so there's got to be a way to instead have it go to a text file, right?

                                      Is there any way to do that?

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

                                        @TPR said in How can I create a "list of games" - Just the titles only?:

                                        Clearly, Emulation Station must pull the data from somewhere to display it on my screen so there's got to be a way to instead have it go to a text file, right?

                                        EmulationStation checks if the file exists on disk before adding it to the list, but it still reads from the gamelist.xml.

                                        You can output the game name and the path at the same time and then read the output in a script that would check if the path is still valid before printing the game. Here's a command that outputs a tab separated list of game path values.

                                        xmlstarlet sel -t -m '//game' -v 'name' -o $'\t' -v 'path' -n gamelist.xml
                                        
                                        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.