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

    [SCRIPT] RetroPie Limit Last Played Games

    Scheduled Pinned Locked Moved Projects and Themes
    shell scriptlast playedgameslimit
    57 Posts 5 Posters 6.2k 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
      MadHorse
      last edited by

      Hi @Clyde and thank you for your help.

      If I understand correctly, the script remove or set to 0 the playcount and don't touch lastplayed, maybe this is the reason is not working, or at least don't seems to work for me.
      In any case, I did wath you asked me, this is the results

      pi@retropie:~/RetroPie/roms/megadrive $ grep lastplayed gamelist.xml
                      <lastplayed>20180626T204249</lastplayed>
                      <lastplayed>20180704T005027</lastplayed>
                      <lastplayed>20180725T124034</lastplayed>
                      <lastplayed>20180725T143844</lastplayed>
       pi@retropie:~/RetroPie/roms/megadrive $ ../retropie-limit-last-played-games.sh -s --nth 1
      Number of 'last played' games to limit is set to '1'.
      
      megadrive
      ---------
      'gamelist.xml' for 'megadrive' found!
      > Creating 'gamelist-backup.xml' for 'megadrive' ...
      There is already a 'gamelist-backup.xml' for 'megadrive'.
      > Removing 'last played' games for 'megadrive' ...
      20180725T124034
      20180704T005027
      20180626T204249
      > Done!
      
      Done!
      pi@retropie:~/RetroPie/roms/megadrive $ grep lastplayed gamelist.xml
                      <lastplayed>20180626T204249</lastplayed>
                      <lastplayed>20180704T005027</lastplayed>
                      <lastplayed>20180725T124034</lastplayed>
                      <lastplayed>20180725T143844</lastplayed>
      

      After this, i opened thegamelist.xml for the megadrive and the file is not modified

      -rw-r--r-- 1 pi pi 1145107 Sep  6 18:03 gamelist-backup.xml
      -rw-r--r-- 1 pi pi   15697 Jun 20 11:58 gamelist.Missing.Serial.txt
      -rw-r--r-- 1 pi pi 1145107 Jul 25 15:41 gamelist.xml
      

      So it seems it create a backup and then don't change anything.

      Thank you for your help, I really appreciate it.

      hiulitH 1 Reply Last reply Reply Quote 0
      • hiulitH
        hiulit @MadHorse
        last edited by

        @madhorse I found the bug! I'll release a new version with additional functionalities. Maybe tomorrow ;)

        My little contributions to the RetroPie project:

        • Shell-Script-Boilerplate
        • Fun-Facts-Splashscreens
        • Limit-Last-Played-Games
        ClydeC 1 Reply Last reply Reply Quote 0
        • ClydeC
          Clyde @hiulit
          last edited by Clyde

          @hiulit According to @MadHorse's test, the script removed three "last played" occurances, while grep listed four of them in the file. Is that part of the bug, or what else caused the discrepancy? Just mentioning to help you debug. :)

          Ah, just ignore me. The script limited the "last played" to one, thus removed three of four. It's too early here in Germany to write in forums, obviously. 😇

          hiulitH 1 Reply Last reply Reply Quote 0
          • hiulitH
            hiulit @Clyde
            last edited by

            @clyde Almost got it! Been working hard, refactoring stuff :P I guess I'll be releasing a new version soonish.

            My little contributions to the RetroPie project:

            • Shell-Script-Boilerplate
            • Fun-Facts-Splashscreens
            • Limit-Last-Played-Games
            1 Reply Last reply Reply Quote 1
            • M
              MadHorse
              last edited by

              @hiulit @Clyde thank you very much for your help.

              hiulitH 1 Reply Last reply Reply Quote 1
              • hiulitH
                hiulit @MadHorse
                last edited by

                @madhorse whoops, sorry, hehe! You were the one with the issue, actually, and I was replying to @Clyde :P

                My little contributions to the RetroPie project:

                • Shell-Script-Boilerplate
                • Fun-Facts-Splashscreens
                • Limit-Last-Played-Games
                M ClydeC 2 Replies Last reply Reply Quote 0
                • M
                  MadHorse @hiulit
                  last edited by

                  @hiulit said in [SCRIPT] RetroPie Limit Last Played Games:

                  @madhorse whoops, sorry, hehe! You were the one with the issue, actually, and I was replying to @Clyde :P

                  hehe no problem :)

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

                    @hiulit I trust you'll work as hard for @MadHorse as you'd have done for me. ;)

                    hiulitH 1 Reply Last reply Reply Quote 1
                    • hiulitH
                      hiulit @Clyde
                      last edited by

                      @clyde @MadHorse Of course ;) hehe!

                      My little contributions to the RetroPie project:

                      • Shell-Script-Boilerplate
                      • Fun-Facts-Splashscreens
                      • Limit-Last-Played-Games
                      1 Reply Last reply Reply Quote 0
                      • hiulitH
                        hiulit
                        last edited by

                        Here it is!

                        RetroPie Limit Last Played Games v2.0.0

                        Read the new docs, as there have been a few changes.

                        Added

                        • Option to install/Uninstall the script from EmulationStation's RetroPie menu.
                        • GUI mode.
                        • Debug mode - To test the script. No harm will done to the gamelists ;)
                        • Log files - Found in /home/pi/Retropie-Limit-Last-Played-Games/logs).

                        Fixed

                        • Uncommented code preventing to actually remove 'last played' games.
                        • Fixed #1 - Only show systems that have a gamelist.xml.

                        Changed

                        • Refactored the code to create backups. Now the folder is called gamelist-backups (inside the $SYSTEM_ROMS folder) and contains all the game lists backups, named [DATE]-gamelist-backup.xml.
                        • Added more error/success output messages.
                        • Better control of what games have to be processed.

                        Examples

                        ./retropie-limit-last-played-games.sh --nth 25 --systems

                        This will set the number of 'last played' games to limit at 25 and then it will show a dialog from where it can be selected as many systems as needed.

                        ./retropie-limit-last-played-games.sh --nth 25 --systems --debug

                        This will set the debug mode on. It's perfect for testing the script before actually 'harming' the gamelists.

                        ./retropie-limit-last-played-games.sh --gui

                        This will start the GUI. It will ask you to enter a number to limit the number of 'last played' the games shown. Then it will ask you to choose the desired systems to apply that limit.

                        Options

                        • --help: Print the help message and exit.
                        • --install: Install the script in EmulationStation's RetroPie menu.
                        • --uninstall: Uninstall the script from EmulationStation's RetroPie menu.
                        • --nth: Set number of 'last played' games to limit per system (10 by default).
                        • --systems: Show dialog to select systems to limit.
                        • --gui: Start the GUI.
                        • --debug: Set debug mode to test the script.
                        • --version: Show script version.

                        My little contributions to the RetroPie project:

                        • Shell-Script-Boilerplate
                        • Fun-Facts-Splashscreens
                        • Limit-Last-Played-Games
                        ClydeC 1 Reply Last reply Reply Quote 1
                        • ClydeC
                          Clyde @hiulit
                          last edited by

                          @hiulit Great work! (without having tested it)

                          1 Reply Last reply Reply Quote 1
                          • M
                            MadHorse
                            last edited by MadHorse

                            @hiulit, first, thank you so much for your work, your work is really appreciated.
                            Second, yout script is awesome, it's working perfectly.
                            Installed the script on the Retropie menu, launched the script, choosed to keep 1 last played game, at the end of the execution you need to restart Emulationstation to see the results.

                            Now my last played list contain only 40 games, one per system :)

                            Thank you again, you did a great job.

                            hiulitH 1 Reply Last reply Reply Quote 1
                            • cyperghostC
                              cyperghost
                              last edited by cyperghost

                              @hiulit I don't want to do a PR but you can add these lines to perform a restart. You can write a small yes/no dialog to perform a restart to ES.

                              # Restart ES!
                              touch /tmp/es-restart
                              chown pi:pi /tmp/es-restart
                              kill $(pidof emulationstation)
                              

                              Best wishes ;)

                              hiulitH 2 Replies Last reply Reply Quote 1
                              • hiulitH
                                hiulit @MadHorse
                                last edited by

                                @madhorse Hey! You're welcome! I'm glad you find it useful :D

                                And you made a good point about EmulationStation having to be restarted to see the changes. I'll add a message to the script .

                                My little contributions to the RetroPie project:

                                • Shell-Script-Boilerplate
                                • Fun-Facts-Splashscreens
                                • Limit-Last-Played-Games
                                1 Reply Last reply Reply Quote 0
                                • hiulitH
                                  hiulit @cyperghost
                                  last edited by

                                  @cyperghost hey, I was just thinking about adding a message but I like your idea better. Thanks for the code ;)

                                  My little contributions to the RetroPie project:

                                  • Shell-Script-Boilerplate
                                  • Fun-Facts-Splashscreens
                                  • Limit-Last-Played-Games
                                  1 Reply Last reply Reply Quote 1
                                  • hiulitH
                                    hiulit @cyperghost
                                    last edited by hiulit

                                    @cyperghost btw, can this code be run under 'sudo'? Because my script has an option be installed in the RetroPie menu and I think the scripts executed from there are run under 'sudo'.

                                    My little contributions to the RetroPie project:

                                    • Shell-Script-Boilerplate
                                    • Fun-Facts-Splashscreens
                                    • Limit-Last-Played-Games
                                    cyperghostC 1 Reply Last reply Reply Quote 1
                                    • cyperghostC
                                      cyperghost @hiulit
                                      last edited by cyperghost

                                      @hiulit Yes but then the file has to be chowend to pi:pi
                                      Added to the codebox

                                      hiulitH 1 Reply Last reply Reply Quote 1
                                      • hiulitH
                                        hiulit @cyperghost
                                        last edited by

                                        @cyperghost the file being 'tmp/es-restart' or my script?

                                        My little contributions to the RetroPie project:

                                        • Shell-Script-Boilerplate
                                        • Fun-Facts-Splashscreens
                                        • Limit-Last-Played-Games
                                        cyperghostC 1 Reply Last reply Reply Quote 0
                                        • cyperghostC
                                          cyperghost @hiulit
                                          last edited by

                                          @hiulit The restart file
                                          Because ES entitiy deletes the file on restart and if it was created by root it won't work

                                          hiulitH 1 Reply Last reply Reply Quote 1
                                          • hiulitH
                                            hiulit @cyperghost
                                            last edited by

                                            @cyperghost got it. Thanks! I'll try it ;)

                                            My little contributions to the RetroPie project:

                                            • Shell-Script-Boilerplate
                                            • Fun-Facts-Splashscreens
                                            • Limit-Last-Played-Games
                                            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.