Created
July 4, 2019 23:38
-
-
Save hsimah/6cb3413f805bf6b83f22bb3ef3323905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function Move-ByDate { | |
param( | |
$Path = '.', | |
$Destination | |
) | |
Get-ChildItem -Path $Path | ForEach-Object { | |
$Date = $_.LastWriteTimeUtc | Get-Date -f yyyy.M | |
$DestPath = Join-Path $Destination $Date | |
if (-not (Test-Path $DestPath)) { | |
New-Item -Path $DestPath -ItemType Directory | |
} | |
Move-Item -Path $_.FullName -Destination $DestPath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment