Trihedraf/Save-Game-Link

Link game saves using NTFS junctions for easy portability and backups

★ 0Forks 0ShellGitHub ↗Compare

README

Save Game Link

Link game saves using NTFS junctions (Windows) or symbolic links (Linux) for easy portability and backups. Keep your game saves in a synced/movable folder and link them back to where games expect them.

Setup

git clone https://github.com/Trihedraf/Save-Game-Link.git
cd Save-Game-Link

Usage

Windows (sgl.ps1):

sgl.ps1                  List all games
sgl.ps1 -All             Process all games
sgl.ps1 -GameName <name> Process a specific game
sgl.ps1 -Check           Check all (or specific game with -GameName) links without making changes
sgl.ps1 -DatabasePath    Path to database file (default: .\db.json)
sgl.ps1 -Help            Show help

Linux (sgl.sh):

./sgl.sh                 List all games
./sgl.sh -a              Process all games
./sgl.sh -g <name>       Process a specific game
./sgl.sh -c              Check all (or specific game with -g) links without making changes
./sgl.sh -d <path>       Path to database file (default: db.json next to the script)
./sgl.sh -h              Show help

How it works

Save files live in data/ under this folder. When you run the script, it creates a directory junction (Windows) or a symbolic link (Linux) from each game's folder in data/ to the expected save location.

This lets you keep your saves in a synced folder or on a portable drive. The links can be recreated on any PC running Windows or Linux, or in a different location, by running the script again.

Environment variables (.env)

Some GOG games store saves in their install folder. If your install isn't in the default location, copy .env.example to .env and set the install dir for each OS you use. Both scripts source .env from the repository root on startup (if it exists).

GOGGAMESWIN=C:/GOG/Games
GOGGAMESLINUX=/home/yourname/Games/GOG

linkWindows values reference variables as $env:GOGGAMESWIN, linkLinux values as ${GOGGAMESLINUX}. The variable names aren't reserved - any variable in .env can be used in path values, e.g. HEROIC_PREFIX pointing at your Heroic prefixes dir for WINE games. Since .env is sourced by bash, quote values that contain backslashes.

Adding a game

Start from db.json.example and edit to your needs. Copy entries from the wiki or create your own.

Each path entry has:

  • origin — the copy of the save under data/, shared by both OSes
  • linkWindows — where the game looks on Windows (entries without it are skipped by sgl.sh)
  • linkLinux — where the game looks on Linux (entries without it are skipped by sgl.ps1)
  • type (optional) — "file" if the target is a single file instead of a directory. Defaults to "dir" when omitted

/ and \ are interchangeable anywhere in origin, linkWindows and linkLinux values - each script normalizes them to its own OS before resolving.

Contributors

Trihedraf

Issues