r/PowerShell • u/spicymeatheheboi • Nov 18 '25
Need Help Writing Script to Fix Gaps in Sequentially Numbered Save Files
I have a folder filled with save files from a Ren'Py game and they are correctly sequenced like this:
1-1-LT1.save
1-2-LT1.save
1-3-LT1.save
1-4-LT1.save
1-5-LT1.save
1-6-LT1.save
2-1-LT1.save
2-2-LT1.save
following this pattern.
Let's say the next three files in the folder need to be renamed:
2-4-LT1.save → 2-3-LT1.save
3-1-LT1.save → 2-4-LT1.save
3-3-LT1.save → 2-5-LT1.save
etc.
I'm looking for a PowerShell script that can rename all the files in the folder to bridge those gaps.
I have no experience with coding and would really appreciate the help.
4
u/ankokudaishogun Nov 18 '25
What is the issue exactly, and what have you tried so far?
0
u/Anaconda077 Nov 18 '25
# yo savefiles$FileList=(Get-Item .\*save | Sort-Object -Property Name).Name# boundary$max_minor=6# counters$counter_major=1$counter_minor=1# file name pattern$pattern="{0}-{1}-LT1.save"# walk through save filesforeach ($OldFile in $FileList) {}First BACK UP savefiles. Then in Powershell navigate to saves folder and run code above to rename files.