Skip to content

Instantly share code, notes, and snippets.

@yuryu
Created May 10, 2020 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuryu/4e3d880ab6b16dca14386930506fe49c to your computer and use it in GitHub Desktop.
Save yuryu/4e3d880ab6b16dca14386930506fe49c to your computer and use it in GitHub Desktop.
$source = '.\Album\'
$destination = '.\Switch\'
Get-ChildItem $source -PipelineVariable year |
ForEach-Object { Get-ChildItem $year.Fullname -PipelineVariable month |
Where-Object { $month.PSIsContainer -eq $true } |
ForEach-Object {
$dest = Join-Path $destination "$year-$month"
New-Item -Path $dest -ItemType 'directory' -Force;
Get-ChildItem $month.FullName -Recurse |
Where-Object { $_.PSIsContainer -eq $false } |
Where-Object { !(Test-Path (Join-Path $dest $_)) } |
ForEach-Object { Copy-Item $_.FullName -Destination $dest }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment