Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created March 6, 2019 11:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfrantz1-r7/edff3b7ca214695c925c5b5de6cb7618 to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/edff3b7ca214695c925c5b5de6cb7618 to your computer and use it in GitHub Desktop.
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