Skip to content

Instantly share code, notes, and snippets.

@mburrough
Created January 11, 2022 05:15
Show Gist options
  • Save mburrough/27df23ed27f7ce42468daba67e5384d6 to your computer and use it in GitHub Desktop.
Save mburrough/27df23ed27f7ce42468daba67e5384d6 to your computer and use it in GitHub Desktop.
PS Script to sort files scanned by Epson SmartScan Invoice Manager into MM\DD folders
#Create month folders
foreach($i in 1..12) { mkdir ("{0:00}" -f $i) }
#Inspect results before doing move
foreach ($file in $files) {
$day = $file.Name.split("_")[2].substring(2).substring(0,2)
$month = $file.Name.split("_")[2].substring(0,2)
$fname = $file.Name
echo "$month $day : $fname"
}
pause
$files = gci -File
foreach ($file in $files) {
$day = $file.Name.split("_")[2].substring(2).substring(0,2)
$month = $file.Name.split("_")[2].substring(0,2)
$fname = $file.Name
echo "$month $day : $fname"
mkdir "$month\\$day"
mv $file "$month\\$day\\$fname"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment