Simple Save State Management

Post Reply
User avatar
GldRush98
Posts: 74
Joined: Wed Aug 08, 2018 12:58 am
languages_spoken: English
ODROIDs: ODROID-Go, ODROID-Go Advance Black Edition
Location: Taylorville, IL
Has thanked: 7 times
Been thanked: 10 times
Contact:

Simple Save State Management

Post by GldRush98 »

I wrote a very basic script that displays a list of save states that exist on your system and allows you to delete any specific state. I've been using this since July and I haven't had any problems with it yet, so I thought I'd share it here in case anyone else could find it useful.

File list display:
Image

Pagination:
Image

Enter the number of the state you'd like to delete, in this case I'm deleting 12, which corresponds to Super Mario Bros:
Image

Save state deleted:
Image

Limitations:
  • It will only look for *.sav files in the home directory. If the emulator is saving states to another location this will not find those.
  • The pagination method is going to be inefficient for a large number of save states. I couldn't think of a better way to do this, and it fits my needs so it is what it is.
To use this, save this script as "Delete Save State.sh" in /opt/system then be sure to:
chmod +x "/opt/system/Delete Save State.sh"

Code: Select all

#!/bin/bash
#Upload this script to /opt/system/
#By: GldRush98
#Last modified: 7/3/2020
cd /home/odroid
FILES=*.sav
TOTAL=1 #Counts total number of files, used in dynamic variable creation
LIMIT=11 #Pagination limit

#Make sure there are sav files to pick from
if stat --printf='' $FILES
then
	#Creates dynamic variables based on the files specified above
	for f in $FILES
	do
		declare "file_$TOTAL=$f"
		((TOTAL=$TOTAL+1))
	done
else
	msgbox "No save states found, so nothing to do."
	exit 0	
fi

str="Select Save State To Delete Via Number:"

#Perform the pagination loops with helpful text on each screen
x=1 #Counts number on current "page"
y=1 #Counts total number displayed
while [ $y -lt $TOTAL ]
do
	while [ $x -le $LIMIT ] && [ $y -lt $TOTAL ]
	do 
		this_file=file_$y
		str+=`echo -e '\n' $y. ${!this_file} `
		((x=$x+1))
		((y=$y+1))
	done
	if [ $y -lt $TOTAL ]
	then
		str+=`echo -e '\n' MORE...`
	else
		str+=`echo -e '\n' Use cancel button on keyboard to not delete any save state.`
	fi
	msgbox "$str"
	str=""
	x=1
done

#Ask user which file to delete, verifies the number is for a file we listed, and deletes if found
delete=`osk "Delete which save state?" | tail -n 1`
delete=`echo $delete | xargs` #trim white space if it gets entered by user
this_file=file_$delete
if [ -f "${!this_file}" ]
then
	rm "${!this_file}"
	msgbox "Deleted - ${!this_file}"
else
	str=`echo -e Invalid file selection: $delete '\n' No save state was deleted.`
	msgbox "$str"
fi
These users thanked the author GldRush98 for the post:
odroid (Mon Oct 12, 2020 11:02 am)

User avatar
rooted
Posts: 8039
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 724 times
Been thanked: 254 times
Contact:

Re: Simple Save State Management

Post by rooted »

This is very useful, thanks for sharing.

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 0 guests