Last active
April 5, 2024 18:38
-
-
Save BooTheDev/c50bc7139dbcec513731d2cd6d5764ca to your computer and use it in GitHub Desktop.
Steam game - Find save, config file location
This file contains 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
# Steam game - Find save/config location | |
$host.UI.RawUI.WindowTitle = "Steam game - Find save/config location" | |
Write-Host " | |
┌───────────────┐ | |
│ Learn to code │ | |
│ Code to learn │ | |
└───────────────┘" | |
Write-Host -ForegroundColor Yellow " | |
*NOTE* | |
This script does not relate to any kind of | |
illegal stuff likes piracy. By taking the | |
advantage of the Steam Cloud feature, it | |
should work in many cases that the game using | |
Steam Cloud storage. It supposes to help Steam | |
users to be easy to find their game save/config | |
files location for personal purpose." | |
Write-Host | |
Write-Host | |
function Get-Root-Location() | |
{ | |
param ( | |
[string]$saveroot | |
) | |
$returnData | |
switch ($saveroot) | |
{ | |
"WinAppDataRoaming" | |
{ $returnData = $env:APPDATA } | |
"WinAppDataLocalLow" | |
{ $returnData = $env:LOCALAPPDATA + "Low" } | |
"WinAppDataLocal" | |
{ $returnData = $env:LOCALAPPDATA } | |
"WinMyDocuments" | |
{ $returnData = $env:USERPROFILE + "\My Documents" } | |
"WinSavedGames" | |
{ $returnData = $env:USERPROFILE + "\Saved Games" } | |
"gameinstall" | |
{ $returnData = "[GameFolder]" } | |
Default | |
{ $returnData = $saveroot } | |
} | |
Write-Output $returnData | |
} | |
function Error-Occur() | |
{ | |
param ( | |
[string]$ErrorMsg | |
) | |
Write-Host | |
Write-Host -ForegroundColor DarkRed ' [Error]' | |
Write-Host | |
Write-Host -ForegroundColor Red "" $ErrorMsg | |
$null = $host.UI.RawUI.ReadKey() | |
exit | |
} | |
$steamUrl = Read-Host -Prompt " Enter the Steam game url" | |
$appid = 0 | |
if ($steamUrl -match "(?<=\.com\/app\/)\d+") | |
{ | |
$appid = [int]$Matches[0] | |
} | |
else | |
{ | |
Error-Occur -ErrorMsg "Can not find Steam appid" | |
} | |
$URI = “https://steamdb.info/app/$($appid)/“ | |
$USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" | |
$HTML = Invoke-WebRequest -Uri $URI -UserAgent $USERAGENT | |
$Ufs0 = $HTML.ParsedHtml.getElementsByTagName("div") | ?{$_.ID -eq "ufs"} | |
$Ufs = ($Ufs0.getElementsByTagName("ul") | Where{ $_.className -eq "app-json" } ).innerText | |
if ($Ufs -eq $null) { | |
Error-Occur -ErrorMsg "Cannot find any info about the save/config | |
location. It may be located in the default | |
directory, which is: | |
[SteamFolder]\userdata\{SteamUserId}\{AppId}" | |
} | |
$DataContent = ($Ufs,$Ufs[0])[$Ufs -is [System.Array]] | |
$DataRoot = ($DataContent | Select-String -Pattern "(?<=\d\/root: )\w+" -AllMatches | ForEach-Object {$_.Matches}) | |
$DataPath = ($DataContent | Select-String -Pattern "(?<=\d\/path: ).+" -AllMatches | ForEach-Object {$_.Matches}) | |
$DataResult = New-Object System.Collections.Generic.HashSet[string] | |
for ($i = 0; $i -lt $DataRoot.Count; $i++) | |
{ | |
[void]$DataResult.Add("$(Get-Root-Location -saveroot $DataRoot[$i].Value)\$($DataPath[$i].Value.replace('/','\'))") | |
} | |
Write-Host | |
Write-Host | |
Write-Host " The save/config game should be located in:" | |
Write-Host | |
$i = 0 | |
foreach ($item in $DataResult) | |
{ | |
Write-Host " $($i):" | |
Write-Host -ForegroundColor Green "" $item | |
Write-Host | |
$i++ | |
} | |
Write-Host Press any key to exit... | |
$null = $host.UI.RawUI.ReadKey() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment