Last active
October 24, 2023 17:28
-
-
Save sonic2kk/be0a0c025df181dee726ca58f265973f to your computer and use it in GitHub Desktop.
Get all Steam Shortcut StartDirs from shortcuts.vdf using Bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Magic that represents 'Startdir' column begin and end | |
# Should always be CamelCase, but you could account for 'startdir' with '7374617274646972' | |
magic_startdir_camelcase="0001537461727444697200" # 'StartDir' | |
magic_startdir_end="0001" # end bytes before next column begins | |
# Paste in your Steam UserID | |
steam_userid="" | |
shortcuts_vdf="$HOME/.steam/root/userdata/${steam_userid}/config/shortcuts.vdf" | |
# Get all Steam Shortcut StartDir values (all values between the magic start and end bytes) | |
mapfile -t non_steam_startdirs < <(xxd -p -c 0 "$shortcuts_vdf" | grep -oP "${magic_startdir_camelcase}\K.*?(?=0001)" ) | |
echo "${non_steam_startdirs[0]}" | |
# Convert from hex and print in loop with trimmed null byte | |
# StartDir will usually contain quotes even when added by Steam itself, though when you browse for StartDir with Steam, it will remove the quotes | |
# You could trim the start and end quotes with - sed -e 's/^"//' -e 's/"$//' | |
# This will simply print them as-is, whether they have quotes or not | |
for i in "${non_steam_startdirs[@]}"; do | |
steam_shortcut_startdir="$( printf "%s\n" "$i" | xxd -r -p | tr -d '\0' )" | |
echo "StartDir: ${steam_shortcut_startdir}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment