43 lines
977 B
PowerShell
Executable File
43 lines
977 B
PowerShell
Executable File
#!/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
|
|
} |