diff --git a/gaming/Slippi/group-replays-by-date.ps1 b/gaming/Slippi/group-replays-by-date.ps1 new file mode 100755 index 0000000..4940249 --- /dev/null +++ b/gaming/Slippi/group-replays-by-date.ps1 @@ -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 +} \ No newline at end of file