Skip to content

Instantly share code, notes, and snippets.

@Eroc33
Created October 20, 2015 12:40
Show Gist options
  • Save Eroc33/5a3ca497a7bf044779fa to your computer and use it in GitHub Desktop.
Save Eroc33/5a3ca497a7bf044779fa to your computer and use it in GitHub Desktop.
$input_folder = "C:\ScannedPDFS\"
$output_folder = "C:\ScannedPDFS\Deskewed\{0}"
### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $input_folder
$watcher.Filter = "*.pdf"
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true
### DEFINE ACTIONS AFTER A EVENT IS DETECTED
$action = {
param($sender, $eventArgs)
$in_file = $eventArgs.FullPath
$out_file = $output_folder -f (Split-Path -Leaf $inFile)
pdfdwcmd.exe $in_file $out_file
}
### DECIDE WHICH EVENTS SHOULD BE WATCHED + SET CHECK FREQUENCY
$created = Register-ObjectEvent $watcher "Created" -Action $action
$changed = Register-ObjectEvent $watcher "Changed" -Action $action
$renamed = Register-ObjectEvent $watcher "Renamed" -Action $action
while ($true) {sleep 5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment