Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A simple PowerShell script to backup Loco Shortline Operations single player save files
- # Twitter: @Kerbo_
- # No changes needed below here
- $ErrorActionPreference = 'SilentlyContinue'
- $locoDir = $env:APPDATA + "\..\LocalLow\TSRS\Loco"
- $dateString = $(get-date -f yyy-MM-dd_HH-mm)
- Push-Location $locoDir
- for ($i = 1; $i -le 6; $i++) {
- $slotsav = Get-Item labstw$i.lab
- $found = ""
- try {
- if(Test-Path -Path $slotsav -PathType Leaf) {
- $found = "True"
- }
- } catch {
- # do nothing
- }
- if($found) {
- $slotsav_hash = Get-FileHash $slotsav
- $backup = gci labstw$i-* | select -last 1
- $backup_hash = Get-FileHash $backup -EV Err -EA SilentlyContinue
- if ( $backup_hash.Hash -eq $slotsav_hash.Hash ) {
- Write-Host "labstw$i.lab matches latest backup, no backup needed" -ForegroundColor green
- } else {
- cp labstw$i.lab labstw$i-$dateString.lab
- $RET=$?
- if ($RET) {
- Write-Host "Copied labstw$i.lab to labstw$i-$dateString.lab" -ForegroundColor yellow
- } else {
- Write-Host "Error! cp returned $RET for labstw$i.lab" -ForegroundColor red
- }
- }
- }
- }
- Pop-Location
- Start-Sleep -Seconds 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement