Untitled
  1. $source = "R:\"
  2. Get-ChildItem -LiteralPath $source -File | ForEach-Object {
  3. $year = $_.LastWriteTime.Year.ToString()
  4. $dest = Join-Path $source $year
  5. if (-not (Test-Path -LiteralPath $dest)) { New-Item -Path $dest -ItemType Directory | Out-Null }
  6. Move-Item -LiteralPath $_.FullName -Destination $dest
  7. }
Pasted 2026-10-06 02:28:56

Short link: