Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function get-destbytype($ext) {
Switch ($ext)
{
{$ext -match '(jpg|png|gif)'} { "images" }
{$ext -match '(txt|docx)'} { "docs" }
default {"$ext" }
}
}
ls $dirtyfolder/* | ? {!$_.PSIsContainer} | %{
$dest = "$($org)ORG\$(get-destbytype $_.extension)"
if (! (Test-Path -path $dest ) ) {
new-item $dest -type directory
}
mv -path $_.fullname -destination $dest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.