Advertisement
kerbo_

WotH-backup.ps1

Aug 17th, 2022 (edited)
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # A simple PowerShell script to backup Way of the Hunter save file
  2. # Twitter: @Kerbo_
  3. #
  4. # Set your Steam ID
  5. # How to find your Steam ID https://www.google.com/search?q=what+is+my+steam+id
  6. # or look at the folder name here %localappdata%\WayOfTheHunter\Saved\SaveGames\Account_xxxxxxxxxxx
  7. # and xxxxxxxxxxx is your Steam ID
  8. $steamID = CHANGEME
  9.  
  10. # No changes needed below here
  11. $wothDir = $env:LOCALAPPDATA + "\WayOfTheHunter\Saved\SaveGames\Account_" + $steamID
  12. $dateString = $(get-date -f yyy-MM-dd_HH-mm)
  13. Push-Location $wothDir
  14.  
  15. $backup = gci SaveData-2* | select -last 1
  16. $backup_hash = Get-FileHash $backup
  17. $wothSave = Get-Item SaveData.sav
  18. $wothSave_hash = Get-FileHash $wothSave
  19.  
  20. #Write-Host "$backup : $backup_hash"
  21. #Write-Host "$wothSave : $wothSave_hash"
  22.  
  23. if ( $backup_hash.Hash -eq $wothSave_hash.Hash ) {
  24.     Write-Host "SaveData.sav matches latest backup, no backup needed" -ForegroundColor green
  25. } else {
  26.     cp SaveData.sav SaveData-$dateString.sav
  27.     $RET=$?
  28.     if ($RET) {
  29.         Write-Host "Copied SaveData.sav to SaveData-$dateString.db" -ForegroundColor yellow
  30.     } else {
  31.         Write-Host "Error! cp returned $RET" -ForegroundColor red
  32.     }
  33. }
  34. Pop-Location
  35. Start-Sleep -Seconds 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement