$HOME/.cleanconfig/retroarch
directory.However, there may be screenshots in the old configuration folder, so it first checks if there are any screenshots in the
$HOME/.config/retroarch/screenshots
directory. If there are, it moves them to a temporary directory, replace the configuration, and restore the screenshots.This is the script I did:
Code: Select all
#!/bin/sh
set -o errexit
set -o nounset
if [ -d "$HOME/.cleanconfig/retroarch" ]
then
screenshots=0
if [ -d "$HOME/.config/retroarch" ]
then
if [ -d "$HOME/.config/retroarch/screenshots" ]
then
if [ -n "$(ls -A "$HOME/.config/retroarch/screenshots")" ]
then
screenshots=1
readonly TemporaryDirectory="$HOME/tempdir-$(date "+%Y-%m-%dT%T")"
mkdir -- "$TemporaryDirectory"
mv -- "$HOME/.config/retroarch/screenshots"/* "$TemporaryDirectory"
fi
fi
rm -r -- "$HOME/.config/retroarch"
fi
cp -R -- "$HOME/.cleanconfig/retroarch" "$HOME/.config"
if [ $screenshots -eq 1 ]
then
mv -- "$TemporaryDirectory"/* "$HOME/.config/retroarch/screenshots"
rm -r -- "$TemporaryDirectory"
fi
else
printf "The %s/.cleanconfig/retroarch directory doesn't exist.\n" "$HOME" 1>&2
exit 1
fi
mktemp
.Would you change/add anything?
Thanks in advance.