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

    Create script to copy and overwrite romlist files in attract mode

    Scheduled Pinned Locked Moved Help and Support
    attract modescriptsromlist
    5 Posts 2 Posters 717 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.
    • D
      drewjbx
      last edited by

      I'm looking to create a script that you can access in a settings section of retropie.
      I am running attract mode and from time to time the romlist files (arcade.txt, consoles.txt) will get corrupted and show 0KB.
      I normally would have to FTP backup files back into /attract/romlists

      With a proper script I could have the backup files stored on the SD card in /backup. Then copy and overwrite all files in the folder into /attract/romlists. I just don't know how to write a script to do that. There is an underlying problem obviously but this would fix the issue for now. Any help would be appreciated!

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

        Do you lack any knowledge in Linux scripting, or what exactly isn't clear to you about it?

        For a start, this command would copy all files from one directory to another:

        cp source/* target/
        

        Can you give us the whole paths of your romlists and the backup? A leading slash would mean that they are located in the system's root directory /, which I highly doubt in your case.

        D 1 Reply Last reply Reply Quote 0
        • D
          drewjbx @Clyde
          last edited by

          @Clyde said in Create script to copy and overwrite romlist files in attract mode:

          Do you lack any knowledge in Linux scripting, or what exactly isn't clear to you about it?

          For a start, this command would copy all files from one directory to another:

          cp source/* target/
          

          Can you give us the whole paths of your romlists and the backup? A leading slash would mean that they are located in the system's root directory /, which I highly doubt in your case.

          I have very little knowledge of linux commands... should take some time to learn these simple ones. I've done ms-dos batch files and such but not quite the same.
          Would this be correct? If so would I just basically create a text file with .SH extension?

          cp  /home/pi/.attract/backup/* /home/pi/.attract/romlists/
          
          1 Reply Last reply Reply Quote 0
          • ClydeC
            Clyde
            last edited by

            Yes, this should copy all files in /home/pi/.attract/backup to /home/pi/.attract/romlists. Beware that this wouldn't copy any subdirectories in backup, for those you'd need the -R option for recursive copying:

            cp  -R /home/pi/.attract/backup/* /home/pi/.attract/romlists/
            

            But if there are only files in backup the -R option isn't needed.

            To make a script out of this, just put this in a text file. It is common to begin a Linux shell script with the shebang which defines the interpreter that should be used to run the script. Without the shebang, the shell will use its standard interpreter that, depending on the script, may cause problems if it handles some commands differently. RetroPie's standard interpreter is the bash, located in /bin.

            Although this shouldn't be an issue with your simple script, let's give it a shebang for sheer sake of completeness:

            #!/bin/bash
            cp  /home/pi/.attract/backup/* /home/pi/.attract/romlists/
            

            Put this into a text file (e.g. sometextfile) and make it executable with this command:

            chmod u+x sometextfile
            

            u+x means give the file's user (i.e. owner) execute permissions.

            Pro tip: If you put this file into a (new) directory /home/pi/bin, it will be found by the shell from any other directory. Otherwise you'd need to invoke it with its full or relative path. If it's in bin in the home directory of the current user, you can run it from anywhere just by its name in the command console.

            As for accessing the script from the Settings section of retropie, I will have to look that up myself since I don't know that off the cuff, but I have to go to work now, so I have to put you off for later. But maybe someone else can take over this part.

            D 1 Reply Last reply Reply Quote 0
            • D
              drewjbx @Clyde
              last edited by

              @Clyde said in Create script to copy and overwrite romlist files in attract mode:

              Yes, this should copy all files in /home/pi/.attract/backup to /home/pi/.attract/romlists. Beware that this wouldn't copy any subdirectories in backup, for those you'd need the -R option for recursive copying:

              cp  -R /home/pi/.attract/backup/* /home/pi/.attract/romlists/
              

              But if there are only files in backup the -R option isn't needed.

              To make a script out of this, just put this in a text file. It is common to begin a Linux shell script with the shebang which defines the interpreter that should be used to run the script. Without the shebang, the shell will use its standard interpreter that, depending on the script, may cause problems if it handles some commands differently. RetroPie's standard interpreter is the bash, located in /bin.

              Although this shouldn't be an issue with your simple script, let's give it a shebang for sheer sake of completeness:

              #!/bin/bash
              cp  /home/pi/.attract/backup/* /home/pi/.attract/romlists/
              

              Put this into a text file (e.g. sometextfile) and make it executable with this command:

              chmod u+x sometextfile
              

              u+x means give the file's user (i.e. owner) execute permissions.

              Pro tip: If you put this file into a (new) directory /home/pi/bin, it will be found by the shell from any other directory. Otherwise you'd need to invoke it with its full or relative path. If it's in bin in the home directory of the current user, you can run it from anywhere just by its name in the command console.

              As for accessing the script from the Settings section of retropie, I will have to look that up myself since I don't know that off the cuff, but I have to go to work now, so I have to put you off for later. But maybe someone else can take over this part.

              Great info... I followed your steps and it works like a charm. I created file in notepadd++ - restore.romlists

              #!/bin/bash
              echo ""
              echo "Restoring Romlists..."
              echo ""
              sleep 5
              cp  /home/pi/.attract/backup/* /home/pi/.attract/romlists/
              

              Put the file into /home/pi/RetroPie/retropiemenu
              chmod u+x the file
              Added the entry in the romlist file retropie.txt (attractmode)
              Created a wheel for it.. all good to go.
              Thanks for the help!

              1 Reply Last reply Reply Quote 1
              • 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.