Skip to content

Instantly share code, notes, and snippets.

@xinmyname
Created March 24, 2011 05:17
Show Gist options
  • Save xinmyname/884612 to your computer and use it in GitHub Desktop.
Save xinmyname/884612 to your computer and use it in GitHub Desktop.
Move files from anywhere to somewhere else
$srcFolder = "W:\"
$dstFolder = "C:\Users\Andy\Temp\pics"
$extensions = ".jpg|.gif|.bmp"
get-childitem -r $srcFolder | where { $_.Extension -match $extensions } |% {
$src = $_
$srcName = $src.Name;
$srcFullName = $src.FullName
$year = $src.LastWriteTime.Year
$month = $src.LastWriteTime.Month
$day = $src.LastWriteTime.Day
$dst = "$dstFolder\$year\$month\$day"
$dstFullName = "$dst\$srcName"
if (-not (test-path $dst)) { mkdir $dst | out-null }
echo "$srcFullName > $dstFullName"
copy $srcFullName $dstFullName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment