From a607faae8837a5e149a5d8c18dc46033895f1181 Mon Sep 17 00:00:00 2001 From: Epic NaN Date: Sat, 1 Jun 2024 17:16:12 +0200 Subject: [PATCH] added Slippi Sorter --- gaming/Slippi/group-replays-by-date.ps1 | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 gaming/Slippi/group-replays-by-date.ps1 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