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

    Skipping "The" in sorting game titles in EmulationStation?

    Scheduled Pinned Locked Moved Help and Support
    retropiesortordersorting roms
    36 Posts 13 Posters 8.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.
    • J
      joemommasfat
      last edited by

      I happen to have written a python script to do just that. You need to hardcode the system(s) that you want to operate on inside the script, and it will change the entries in your gamelist.xml and then it will OVERWRITE your existing gamelist.xml file. PLEASE make a backup copy of your gamelist.xml (gamelist.xml.bak) before running this

      I use this on my own system without any problems, and I hope it works for you, but I can't make any guarantees.

      #!/usr/bin/env python
      
      import xml.etree.ElementTree as ET
      
      ## root location of gamelists
      xmldir='/home/pi/.emulationstation/gamelists/'
      
      ## hardcoded list of gamelist subdirectories to modify
      #systemlist=['snes', 'genesis', 'gba', 'gb', 'gbc', 'atari2600', 'nes', 'pcengine','gamegear']
      systemlist=['snes']
      
      ## loop through systems
      for system in systemlist:
      
        xmlfile = xmldir+system+'/gamelist.xml'
      
        ## parse the gamelist file
        tree=ET.parse(xmlfile)
        root=tree.getroot()
      
        ## loop through games
        for game in root:
          name = game.find('name').text
      
          ## check if game starts with 'The '
          if name[0:4] == 'The ':
            
            ## search for a ':' in the name e.g. The Addams Family: Pugsley's Scavenger Hunt
            iend=name.find(':')
      
            if iend != -1:  ## if ':' exist
              ## Insert ', The' right before ':'
              ## Addams Family, The: Pugsley's Scavenger Hunt
              name2=name[4:iend]+', The'+name[iend:]
            else:  ## if ':' does not exist
              ## Append ', The' at the end
              name2=name[4:]+', The'
      
            ## replace the game name
            print 'changing "'+name+'" to "'+name2+'"'
            #game.set('name',name2)
            game.find('name').text=name2
      
        print 'writing '+xmldir+system+'/gamelist.xml'
        tree.write(xmldir+system+'/gamelist.xml',encoding="UTF-8")
      
      J S 2 Replies Last reply Reply Quote 1
      • J
        jell @joemommasfat
        last edited by

        @joemommasfat That's great! As a newbie python coder, just curious about the formatting of the resulting xml file. Does it come out indented appropriately (with amount of indentation based on the xml hierarchy)? I always ended up with what appeared to be all of the text on a single line when manipulating xml, which made for difficulty in readability when editing. I ended up finding some code on the internet to indent the xml appropriately, but if there's a way to do without, I could clean up my code a bit.

        Thanks!

        1 Reply Last reply Reply Quote 0
        • J
          joemommasfat
          last edited by

          It comes out formatted with 8 space indentations for sub elements. Here is an excerpt of my snes gamelist (for a modified entry).

          <?xml version="1.0"?>
          <gameList>
                  </game>
                  <game id="3669" source="theGamesDB.net">
                          <path>./Addams Family, The - Pugsley's Scavenger Hunt (USA).zip</path>
                          <name>Addams Family, The: Pugsley's Scavenger Hunt</name>
                          <desc>As if things weren't ooky enough!...</desc>
                          <image>~/.emulationstation/downloaded_images/snes/Addams Family, The - Pugsley's Scavenger Hunt (USA)-i
          mage.jpg</image>
                          <releasedate>19930201T000000</releasedate>
                          <developer>Ocean</developer>
                          <publisher>Ocean</publisher>
                          <genre>Platform</genre>
                          <players>1</players>
                  </game>
          </gameList>
          
          1 Reply Last reply Reply Quote 0
          • J
            jell
            last edited by

            Thanks, that's very interesting. Will play around more next time I write a script for the gamelist. Maybe it was just when I added new subelements that those weren't indented like the others, not sure anymore. I also didn't use the encoding parameter in the tree.write. Thanks again for reply!

            1 Reply Last reply Reply Quote 0
            • S
              sub_atomic @joemommasfat
              last edited by sub_atomic

              @joemommasfat Thanks for sharing the Python script. It is a workaround, but I really don't like the look of ", The" at the end of game titles. There has to be a way for ES to skip "The" when sorting games in the GUI, so that your games would sort like this:

              Kirby Super Star
              Kirby's Dream Land 3
              The Legend of the Mystical Ninja
              The Legend of Zelda: A Link to the Past
              Lemmings
              Lord of Darkness
              The Lost Vikings
              Lufia & the Fortress of Doom
              Magical Pop'n
              The Magical Quest Starring Mickey Mouse
              Mario Paint
              Mega Man 7

              1 Reply Last reply Reply Quote 0
              • J
                jell
                last edited by

                Not sure, I guess it's a matter of preference. I prefer the sorting as it is, with all the games in a group to start with the same letter, makes it easier to scan through them for me.

                S 1 Reply Last reply Reply Quote 0
                • S
                  sub_atomic @jell
                  last edited by sub_atomic

                  @jell You walk into a record store, where are The Beatles, in the B's or the T's? Proper alphabetical sorting should always ignore articles.

                  1 Reply Last reply Reply Quote 0
                  • J
                    joemommasfat
                    last edited by

                    I guess the short answer is no, that is not a current feature of emulationstation. It has been mentioned before, but so far no one has implemented it.

                    Why not take a crack at it?

                    https://github.com/RetroPie/EmulationStation/blob/master/es-app/src/FileSorts.cpp

                    S 1 Reply Last reply Reply Quote 0
                    • Used2BeRXU
                      Used2BeRX
                      last edited by

                      I'd really like to see this feature coded into EmulationStation. I can't believe after 20+ years of emulation that this is still an issue. "The" should not be displayed in the T's unless the next word begins with T. Putting ", The" at the end of a game looks hideous, and is just a lazy way to "fix" this problem.

                      I'm hoping that somebody who knows how to do these things finally makes this a feature in EmulationStation since emulation on the Pi seems to have a very long future ahead of it.

                      In the mean time, all of my games on every console will just have a long list of games that start with "The" until somebody codes this. I refuse to put ", The" at the end of the game titles.

                      Sorry if that came off as rude. I'm usually pretty happy go lucky, but this issue has been a huge pet peeve of mine for 20 years now. :)

                      BuZzB 1 Reply Last reply Reply Quote 1
                      • BuZzB
                        BuZz administrators @Used2BeRX
                        last edited by BuZz

                        @used2berx Make a suggestion - offer some ideas, but don't get agitated about it. If it upsets you so much, have you submitted a fix ?

                        I really dislike it when people come across as entitled - as if somehow you are owed. The original author of ES never implemented this. No-one else has done it either. 20 years of emulation has nothing to do with it.

                        Maybe someone will find the time, but moaning about it does nothing but annoy people.

                        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                        Used2BeRXU 1 Reply Last reply Reply Quote 2
                        • Used2BeRXU
                          Used2BeRX @BuZz
                          last edited by

                          @buzz I've spent years of my life doing work for the community, and I continue to do it now. I'm not entitled, and I'm not acting entitled. I'm not moaning, and I said so in my post. I also apologized ahead of time if that came off as rude to anybody, so I'm not sure you got to the end of my post before you replied.

                          I'm not a coder, and I don't care to learn how to code. I do the other work that anybody could do but nobody is crazy or OCD enough to do. I was just mentioning that it's ugly and I can't believe that nobody in 20 years has ever done this anywhere.

                          BuZzB 1 Reply Last reply Reply Quote 0
                          • BuZzB
                            BuZz administrators @Used2BeRX
                            last edited by BuZz

                            @used2berx Instead of making the post and apologising at the end, maybe don't come across that way ?

                            Don't forget that I have also read all your moaning and swearing over at another forum about RetroPie.

                            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                            Used2BeRXU 1 Reply Last reply Reply Quote 2
                            • Used2BeRXU
                              Used2BeRX @BuZz
                              last edited by Used2BeRX

                              @buzz You shouldn't post that site name. They offer roms there.

                              Thanks. :)

                              BTW... I have had a lot of good things to say about RetroPie, and if you read the bad stuff, you should probably take the time to read on and see how much I've been hyping it the last few months. My initial impressions were not good, but I do see a lot of potential.

                              The fix I want done can't be done on the XBox. It takes too many resources and would break a few of the emulators that are already pushing the limits of the system to the max. It would just be nice if we could get that to happen on the Pi 3 that shouldn't have any problems handling the extra workload is all.

                              1 Reply Last reply Reply Quote 0
                              • S
                                sub_atomic @joemommasfat
                                last edited by sub_atomic

                                @joemommasfat That's a slightly different request than mine, but a good one also. Could be fixed by sorting game titles by Name, then Release Date.

                                Coding these changes is WAY beyond my capabilities, but I might know a guy who can make it happen. Haven't talked to him in years, but I'll send this to him and see what he says, thanks.

                                1 Reply Last reply Reply Quote 0
                                • J
                                  joemommasfat
                                  last edited by

                                  Give this a try.

                                  https://github.com/Joemommasfat/EmulationStation/commit/b02b9bfd8f23307625b0045101e67e23a5271ef0

                                  If you want to use this, change line 139 of ~/RetroPie-Setup/scriptmodules/supplementary/emulationstation.sh

                                      #[[ -z "$repo" ]] && repo="https://github.com/RetroPie/EmulationStation"
                                      [[ -z "$repo" ]] && repo="https://github.com/Joemommasfat/EmulationStation"
                                  

                                  Then install emulation station from source.

                                  After that, add a "sortname" entry to your gamelist.xml and it will sort on that rather than the default name. I tested it with the entry below, and Super mario world went to the top of the list in ES.

                                                  <name>Super Mario World</name>
                                                  <sortname>1111AAAAA</sortname>
                                                  <desc>Mario’s off on his biggest
                                  

                                  If this works for people, I can put in a pull request and see if it gets into the retropie git.

                                  Z meleuM S 3 Replies Last reply Reply Quote 1
                                  • Z
                                    Zigurana @joemommasfat
                                    last edited by

                                    @joemommasfat
                                    Interesting approach, why not stripping out any article (if any) before doing the comparison in Filesorts.cpp?
                                    There is little need to actually storing the scrubbed game-name, unless you foresee a use case for manually setting the sort order to something else?

                                    If tetris has thought me anything, it's that errors pile up and that accomplishments dissappear.

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      joemommasfat
                                      last edited by

                                      Well personally I've always wished Final Fantasy IX was listed after Final Fantasy VII in my list. Now I can set the "sortnames" to "Final Fantasy 9" and "Final Fantasy 7" but keep the display names with Roman numerals.

                                      Z Used2BeRXU 2 Replies Last reply Reply Quote 0
                                      • Z
                                        Zigurana @joemommasfat
                                        last edited by

                                        @joemommasfat
                                        I see, good. I like that your PR is nicely conservative in the sense that you only need to set a sort-name if you need to, as it falls back nicely on the regular game name.

                                        To build on that, I think we will need some additional work if we want to support sorting of game franchise series, especially across platforms (tag @pjft). Maybe a combination of sort by name and date, or based on another new metadata entry called "series" or "franchise"?

                                        If tetris has thought me anything, it's that errors pile up and that accomplishments dissappear.

                                        1 Reply Last reply Reply Quote 0
                                        • meleuM
                                          meleu @joemommasfat
                                          last edited by

                                          @joemommasfat said in Skipping "The" in sorting game titles in EmulationStation?:

                                          If you want to use this, change line 139 of ~/RetroPie-Setup/scriptmodules/supplementary/emulationstation.sh

                                          Maybe using es-tests.sh can be simpler and avoid confusion. I posted about it here: https://retropie.org.uk/forum/topic/10626/es-devs-and-testers-this-tool-is-for-you

                                          • Useful topics
                                          • joystick-selection tool
                                          • rpie-art tool
                                          • achievements I made
                                          1 Reply Last reply Reply Quote 1
                                          • Used2BeRXU
                                            Used2BeRX @joemommasfat
                                            last edited by Used2BeRX

                                            @joemommasfat said in Skipping "The" in sorting game titles in EmulationStation?:

                                            Well personally I've always wished Final Fantasy IX was listed after Final Fantasy VII in my list. Now I can set the "sortnames" to "Final Fantasy 9" and "Final Fantasy 7" but keep the display names with Roman numerals.

                                            That's a good solution you came up with there. Is there a way to automate this by comparing roman numerals to exact titles that also have them? That way you wouldn't have to go in and manually edit the gamelist.xml to make it happen.

                                            We've been able to do that on the XBox for quite some time, actually. I'm going to talk to the dev and see what he did to make it work. I know it's automatic there. Maybe that would give us some ideas how to do it over here?

                                            EDIT: The other problem was with games like Super Mario Bros. Before the fix on the XBox went in, unless you named them all Super Mario Bros. I, Super Mario Bros. II and Super Mario Bros. III, the first game would be at the end like this:

                                            Super Mario Bros. 2
                                            Super Mario Bros. 3
                                            Super Mario Bros

                                            dankcushionsD 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.