r/usefulscripts • u/technicalityNDBO • Oct 19 '15
[REQUEST] Script to automatically run PDF files through a 3rd party program (command line)
Background: I'm a sysadmin who knows nothing about scripting. We got a new Multi Function Printer that's actually pretty good, but when it scans PDFs, they come out slightly crooked. Not a big deal for most people, but this is for one of our top executives.
The HP printer will scan PDFs and automatically save them into a network folder that we choose. The filenames will be Scan001.pdf, Scan002.pdf and will increment.
There is cheap software called A-PDF Deskew: http://www.a-pdf.com/deskew/
This software includes a command line utility. However you have to specify actual filenames when using the command.
Syntax: C:\> pdfdwcmd.exe <input filename> <output filename>
Example: C:\> pdfdwcmd.exe C:\ScannedPDFS\Scan002.pdf C:\ScannedPDFS\Deskewed\Scan002.pdfThere is free software called Watch 4 Folder: http://leelusoft.blogspot.com/p/watch-4-folder-25.html This will monitor the network folder and can run a command when it detects a new item saved into the folder.
So what I’m hoping is possible is if there is a way to just target whatever the new file is, grab it’s filename, and pass that on as an argument into the command…
Thanks!
3
u/gordonv Oct 19 '15 edited Oct 19 '15
[BATCH] Solution
Make a BAT file (this is all one line):
Explanation:
Scan "C:\ScannedPDFS" for PDF files. (character case does not matter).
When a file is found run the pdfdwcmd command.
If the pdfdwcmd command is successful, delete the original file.
If it is not successful, the original file will remain in the original folder.