Skip to content

Instantly share code, notes, and snippets.

@joeybaumgartner
Created September 1, 2023 12:54
Show Gist options
  • Save joeybaumgartner/981757bcee070d0296768acc66ff24f6 to your computer and use it in GitHub Desktop.
Save joeybaumgartner/981757bcee070d0296768acc66ff24f6 to your computer and use it in GitHub Desktop.
Utility to rename PS game saves
[CmdletBinding()]
param (
[Parameter()]
[string]
$Path,
[Parameter()]
[string]
$PsxList
)
$Header = (Get-Content -Path $PsxList -TotalCount 1).Split(';')
$Csv = Import-Csv $PsxList -Delimiter ';' -Header $Header
$FileList = Get-ChildItem -Path $Path -Filter "*.psv"
$GameIdLength = 8
ForEach ($FileName in $FileList) {
$GameId = $FileName.Name.Substring(2, 2 + $GameIdLength)
$UniqueId = $FileName.Name.Substring(2 + 2 + $GameIdLength)
$Title = $csv | Where-Object { $_.GameID -eq $GameId}
if($Title.Length -gt 0) {
if($UniqueId.Length -gt 0) {
$NewName = "$($Title.Name)_$UniqueId"
}
else {
$NewName = $Title.Name
}
Write-Host "Renaming $($FileName.Name) to $NewName"
Rename-Item -Path $FileName -NewName $NewName
}
}
@joeybaumgartner
Copy link
Author

Notes

This script will only act on .psv files. It will go through the directory and rename each file based upon the PlayStation GameID specified. The new name format is <Title>_.psv. NOTE: If no Unique ID is found, the files will instead just be the name of the game title.

Warning

Make a backup of these files first. While this script does not touch the contents of each file, I cannot guarantee that there are no errors in the PlayStation game id file used.

Parameters

  • Path: the path to where the files are saved (again, .psv files only)
  • PsxList: the path to a csv file (that uses semi-colons for delimiters) containing at least a column named GameID and a column named Title to map the filenames appropriately.

@joeybaumgartner
Copy link
Author

I did find a PS2 game ID list here, and used it for testing this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment