$source = "R:\" Get-ChildItem -LiteralPath $source -File | ForEach-Object { $year = $_.LastWriteTime.Year.ToString() $dest = Join-Path $source $year if (-not (Test-Path -LiteralPath $dest)) { New-Item -Path $dest -ItemType Directory | Out-Null } Move-Item -LiteralPath $_.FullName -Destination $dest }