From 701b476dd93fc586592ad53f388311f7d88b0194 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:30:59 -0700 Subject: [PATCH] better backup system --- NonSteamLaunchers.sh | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/NonSteamLaunchers.sh b/NonSteamLaunchers.sh index f3d9e96..b225607 100755 --- a/NonSteamLaunchers.sh +++ b/NonSteamLaunchers.sh @@ -2359,23 +2359,13 @@ if [[ -n "$userdata_folder" ]]; then # Check if shortcuts_vdf_path is not empty if [[ -n "$shortcuts_vdf_path" ]]; then # Create backup of shortcuts.vdf file - cp "$shortcuts_vdf_path" "$shortcuts_vdf_path.bak" + cp "$shortcuts_vdf_path" "$shortcuts_vdf_path.bak_$(date +%Y%m%d_%H%M%S)" else - # Find config directory for current user - config_dir=$(find "$userdata_folder" -maxdepth 1 -type d -name config) + # Find or create config directory for current user + config_dir=$(find "$userdata_folder" -maxdepth 1 -type d -name config || mkdir -p "$userdata_folder/config/" && echo "$userdata_folder/config/") - # Check if config_dir is not empty - if [[ -n "$config_dir" ]]; then - # Create new shortcuts.vdf file at expected location for current user - touch "$config_dir/shortcuts.vdf" - shortcuts_vdf_path="$config_dir/shortcuts.vdf" - else - # Create new config directory and new shortcuts.vdf file at expected location for current user - mkdir "$userdata_folder/config/" - touch "$userdata_folder/config/shortcuts.vdf" - config_dir="$userdata_folder/config/" - shortcuts_vdf_path="$config_dir/shortcuts.vdf" - fi + # Create new shortcuts.vdf file at expected location for current user + touch "$config_dir/shortcuts.vdf" fi else # Userdata folder was not found