Last active
March 1, 2022 01:00
-
-
Save greatb/75e035639eeb38dc286020626e1f5ef5 to your computer and use it in GitHub Desktop.
PS script to group the files by created year-month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SourceFolder = "E:\Sorce" | |
$outputDir = "e:\Photos-Grouped" | |
$files = Get-ChildItem -Path $SourceFolder -Recurse | Where-Object {$_.PSIsContainer -eq $false} | |
foreach ($file in get-ChildItem $files) { | |
$toDir = Join-Path $outputDir $file.lastwritetime.toString("yyyy\\yyyy-MM") | |
$toFile = Join-Path $toDir $file.name | |
if(!(Test-Path $toDir)) | |
{ | |
New-Item -Path $toDir -ItemType Directory -Force | Out-Null | |
} | |
Echo $toFile | |
Copy-Item -Path $file.FullName -Destination $toFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment