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

    Clearing the lastplayed and playcount from gamelist.xml's

    Scheduled Pinned Locked Moved Ideas and Development
    clearinglastplayedplaycountgamelist.xml
    34 Posts 13 Posters 14.4k 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.
    • I
      Invisible89 @mitu
      last edited by Invisible89

      @mitu said in Clearing the lastplayed and playcount from gamelist.xml's:

      @davidgrohl The script fragment expects the gamelist.xml located in the ROMs folders, but by default they're in /home/pi/.emulationstation/gamelists/<system_name>. Try the script posted by @kactius, it allows you to select one of the 2 locations for the gamelist.xml files.

      Hi guys.

      I'm trying to clear my last played games list, but it doesn't work :(

      I've created cleanlastplayed.sh file with this code:

      #!/bin/sh
      #clear_played.sh

      for f in /home/pi/RetroPie/roms/**/gamelist.xml
      do
      echo "file: $f"
      grep -e lastplayed -e playcount -v $f > "$f.tmp"
      mv -f "$f.tmp" $f
      done

      It's ok? Or I've to modify it with the name of the system name (**)?

      And where should I put this file? What directory?

      Thanks

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

        You should use a single wildcard (*) instead of the system name, but the script will only find the gamelist.xml files from the ROM folders, you might have some gamelist files in ~/.emulationstation/gamelists/<system> folders.

        I 1 Reply Last reply Reply Quote 0
        • I
          Invisible89 @mitu
          last edited by

          @mitu said in Clearing the lastplayed and playcount from gamelist.xml's:

          You should use a single wildcard (*) instead of the system name, but the script will only find the gamelist.xml files from the ROM folders, you might have some gamelist files in ~/.emulationstation/gamelists/<system> folders.

          Ok, i will try with only one windcard.

          But where i've to put my cleanlastplayed.sh file?

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

            @Invisible89 said in Clearing the lastplayed and playcount from gamelist.xml's:

            But where i've to put my cleanlastplayed.sh file?

            It doesn't matter, as long as you execute it correctly. Let's say you save it in /home/pi/RetroPie/scripts.

            #make the folder
            mkdir -p $HOME/RetroPie/scripts
            
            # create the file in $HOME/RetroPie/scripts/lastplayed.sh
            
            # run the script
            bash $HOME/$HOME/RetroPie/scripts/lastplayed.sh
            
            I 2 Replies Last reply Reply Quote 0
            • I
              Invisible89 @mitu
              last edited by

              @Invisible89 said in Clearing the lastplayed and playcount from gamelist.xml's:

              @mitu said in Clearing the lastplayed and playcount from gamelist.xml's:

              You should use a single wildcard (*) instead of the system name, but the script will only find the gamelist.xml files from the ROM folders, you might have some gamelist files in ~/.emulationstation/gamelists/<system> folders.

              Ok, i will try with only one windcard.

              But where i've to put my cleanlastplayed.sh file?

              Ok, i understand.

              Thanks

              1 Reply Last reply Reply Quote 0
              • I
                Invisible89 @mitu
                last edited by

                @mitu said in Clearing the lastplayed and playcount from gamelist.xml's:

                @Invisible89 said in Clearing the lastplayed and playcount from gamelist.xml's:

                But where i've to put my cleanlastplayed.sh file?

                It doesn't matter, as long as you execute it correctly. Let's say you save it in /home/pi/RetroPie/scripts.

                #make the folder
                mkdir -p $HOME/RetroPie/scripts
                
                # create the file in $HOME/RetroPie/scripts/lastplayed.sh
                
                # run the script
                bash $HOME/$HOME/RetroPie/scripts/lastplayed.sh
                

                Ok, now I've this when I try to run the script:

                pi@retropie:~/RetroPie/scripts $ ./delete_pla_last.sh
                -bash: ./delete_pla_last.sh: Permission denied

                What I've to do to take a permission?

                Thanks

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

                  @Invisible89 said in Clearing the lastplayed and playcount from gamelist.xml's:

                  What I've to do to take a permission?

                  It's because you've not made the script executable - that's why in my example command I've run it through bash. Just run

                  chmod +x delete_pla_last.sh
                  

                  and re-run the script.

                  I 1 Reply Last reply Reply Quote 0
                  • I
                    Invisible89 @mitu
                    last edited by

                    @mitu said in Clearing the lastplayed and playcount from gamelist.xml's:

                    @Invisible89 said in Clearing the lastplayed and playcount from gamelist.xml's:

                    What I've to do to take a permission?

                    It's because you've not made the script executable - that's why in my example command I've run it through bash. Just run

                    chmod +x delete_pla_last.sh
                    

                    and re-run the script.

                    Finally! ;)

                    Done, thank you man!

                    1 Reply Last reply Reply Quote 0
                    • R
                      RetrOkada
                      last edited by

                      Hello, thanks for this script.

                      Unfortunately, when I attempt to run it, I receive the following message:
                      "
                      Clearlastplayed.sh, : 3:, clearlastplayed.sh, : syntax error: redirection unexpected
                      "

                      Anyone know what this means?

                      Cheers.

                      R 1 Reply Last reply Reply Quote 0
                      • R
                        RetrOkada @RetrOkada
                        last edited by

                        @RetrOkada Okay, so all sorted now. To run the script, I was entering sh "clearlastplayed.sh". I tried ./clearlastplayed.sh instead, and it worked perfectly.

                        I also removed the DOS line breaks from the script, so circumvented the "Bad Interpreter" issue.

                        1 Reply Last reply Reply Quote 0
                        • S
                          ssokolow
                          last edited by

                          Sorry for replying half a year later, but this is showing up in Google results and using grep to edit an XML file risks corrupting it if something else broke the assumption that it's pretty-printed in the right way.

                          (eg. Python's ElementTree XML library outputs minified XML by default and it took a few revisions to turn on pretty-printing in one of the scripts I wrote.)

                          The device I'm currently preparing for a family Christmas gift is using Batocera rather than RetroPie, but my solution for this should work on RetroPie too as long as it's got a standard Python 3.x installation.

                          https://gist.github.com/ssokolow/e1c4b6fceb65bcf4e6d886ce691280bf

                          (As you can probably tell, I got a little nerd-sniped about making it robust and friendly before I realized I was going way overboard for a self-itch-scratch and stopped short of writing an automated test suite.)

                          To just clear lastplayed and playcount without also clearing gametime, pass --remove-tag lastplayed --remove-tag playcount as arguments.

                          LolonoisL 1 Reply Last reply Reply Quote 2
                          • LolonoisL
                            Lolonois @ssokolow
                            last edited by Lolonois

                            @ssokolow Nice work. Works like charm on a RetroPie setup too. Thanks for sharing it under MIT license.

                            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.