added Slippi Sorter

This commit is contained in:
Epic NaN 2024-06-01 17:16:12 +02:00
parent d21b7940f7
commit a607faae88
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
#!/usr/bin/pwsh
#
# author: arian furrer
# date: 2024-06-01
#
#
# This script copies Slippi replays into sub-folders in case you
# forgot to set the flag that already does that. Mainly used
# for older replays
#
#
# Usage:
# ./group-replays-by-date.ps1 -InputDir /path/to/in -OutputDir /path/to/out
#
param(
[Parameter(Mandatory)]
[String]$InputDir,
[Parameter(Mandatory)]
[String]$OutputDir
)
$AllFiles = $( Get-ChildItem -Path $InputDir -Filter 'Game_*.slp' -Depth 1 )
ForEach ($f in $AllFiles) {
$FileName = $f.Name
$FilePath = $f.FullName
$DateString = $( ( $FileName.Split("_").Split("T") )[1] )
$NewDateString = $( [datetime]::ParseExact($DateString,"yyyyMMdd",$null) ).ToString('yyyy-MM')
$NewOutputDir = $( Join-Path $OutputDir $NewDateString )
if ( -not ( Test-Path $NewOutputDir ) ) {
New-Item -Path $NewOutputDir -ItemType Directory
}
Copy-Item -Path $FilePath -Destination $( Join-Path $NewOutputDir $FileName ) -Verbose
}