suspicious smells in mudville
[feisty_meow.git] / scripts / customize / fred / scripts / games / gamesaver.sh
1 #!/bin/bash
2
3 # a helpful script that scrapes any active game saves from wine's storage
4 # area into a spooling saves folder for archiving.
5
6 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
7
8 # copies the files for a particular game out to a spooling folder.
9 function copyem()
10 {
11   game_name="$1"; shift
12   source_dir="$1"; shift
13   out_dir="$1"; shift
14
15   if [ -d "$source_dir" -a $(ls "$source_dir" 2>/dev/null | wc -c) != 0 ]; then
16     echo $game_name
17     if [ ! -d "$out_dir" ]; then
18       mkdir -p "$out_dir"
19       exit_on_error "Creating storage dir: $out_dir"
20     fi
21     netcp "$source_dir"/* "$out_dir"/
22     sep 28
23   fi
24 }
25
26 ##############
27
28 # run through and copy our save files from the potentially weird locations they reside in.
29 # this requires a single argument, which is the top-level directory of the game storage.
30 function copy_all_save_games()
31 {
32   local WINE_GOODS_DIR="$1"
33
34   local WINE_GAMES_DIR="$WINE_GOODS_DIR/My Games"
35   local SPOOLING_OUTPUT_DIR="$HOME/data/spooling_saves"
36
37   if [ ! -d "$WINE_GAMES_DIR" ]; then
38     echo "Failing to find the game save directories."
39     exit 1
40   fi
41
42   if [ ! -d "$SPOOLING_OUTPUT_DIR" ]; then
43     mkdir -p "$SPOOLING_OUTPUT_DIR"
44     exit_on_error Creating spooling output directory.
45   fi
46
47   sep 28
48
49   copyem "skyrim" "$WINE_GAMES_DIR/Skyrim/Saves" "$SPOOLING_OUTPUT_DIR/skyrim"
50
51   copyem "fallout new vegas" "$WINE_GAMES_DIR/FalloutNV/Saves" "$SPOOLING_OUTPUT_DIR/fallout_new_vegas"
52
53   copyem "fallout 3" "$WINE_GAMES_DIR/Fallout3/Saves" "$SPOOLING_OUTPUT_DIR/fallout_3"
54
55   copyem "oblivion" "$WINE_GAMES_DIR/Oblivion/Saves" "$SPOOLING_OUTPUT_DIR/oblivion/"
56
57   copyem "fallout 4" "$WINE_GAMES_DIR/Fallout4/Saves" "$SPOOLING_OUTPUT_DIR/fallout_4"
58
59   copyem "witcher 3" "$WINE_GOODS_DIR/The Witcher 3/gamesaves" "$SPOOLING_OUTPUT_DIR/witcher_3"
60 }
61
62 # mainline of script tries out a few locations to back up.
63
64 # first try our play on linux storage.  very individualized for fred.
65 wine_goods_dir="$HOME/linx/wine_goods"
66 if [ ! -d "$wine_goods_dir" ]; then
67   wine_goods_dir="/cygdrive/c/users/fred/My Documents"
68 fi
69 if [ ! -d "$wine_goods_dir" ]; then
70   echo "not trying to back up any wine goods; could not find an appropriate folder."
71 else
72   copy_all_save_games "$wine_goods_dir"
73 fi
74
75 # now try the main linux steam save game storage area, which is also fred specific.
76 # this uses a link in the home directory called steam_goods which is connected to
77 # "$HOME/.steam/steam/SteamApps/compatdata/MYNUM/pfx/drive_c/users/steamuser/My Documents"
78 # where MYNUM is replaced with one's steam ID number.
79 wine_goods_dir="$HOME/linx/steam_goods"
80 if [ ! -d "$wine_goods_dir" ]; then
81   echo "not trying to back up any steam goods; could not find an appropriate folder."
82 else
83   copy_all_save_games "$wine_goods_dir"
84 fi
85
86