Create script to copy and overwrite romlist files in attract mode
-
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/romlistsWith 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!
-
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. -
@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/
-
Yes, this should copy all files in
/home/pi/.attract/backup
to/home/pi/.attract/romlists
. Beware that this wouldn't copy any subdirectories inbackup
, 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 inbin
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.
-
@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 inbackup
, 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 inbin
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!
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.