pdf - Applescript to (if/then) determine file type and choose correct program to open and print file (within batch sequence) -
i have culled applescript great @chuck , other board posts batch print list of files exported filemaker containers folder called "print" on desktop.
the problem i'm running of container exports not pdf (its mix of jpg, png, tif , pdf) , not open using acrobat (using preview pdf or other pdf viewer out of question myriad of reasons)... problem shutting down work flow because of error messages acrobat must manually clicked off before script proceed next file.
my question can applescript commanded determine file type first , choose different program open document , trigger print command , close window before moving onto next document in sequence.
(i.e. if .pdf use acrobat print close window, if not use preview open file, print close window, repeat until files have been printed.)
below current working code.(fyi) script running within filemaker script creating "print" folder on desktop , exporting container fields folder.
`set myfolder (path desktop folder text) & "print:"
set myfiles list folder myfolder without invisibles
repeat myfile in myfiles
set mycurrentfile ((myfolder string) & (myfile string)) string batchprint(mycurrentfile)
end repeat
on batchprint(mycurrentfile)
tell application "adobe acrobat pro" activate -- bring acrobat open alias mycurrentfile -- acrobat opens new file tell application "system events" tell process "acrobat" click menu item "print..." of menu 1 of menu bar item "file" of menu bar 1 click button "print" of window "print" tell application "system events" tell process "acrobat" click menu item "close" of menu 1 of menu bar item "file" of menu bar 1 end tell end tell end tell end tell end tell tell application "finder" -- move printed file out set x ((path desktop folder text) & "printed pdfs:") if alias x exists beep else make new folder @ desktop properties {name:"printed pdfs"} end if move alias mycurrentfile folder "printed pdfs" end tell
end batchprint`
use finder test file type , extension, use acrobat tell block if it's pdf, , use preview or whatever if not. here's code structure that:
tell application "finder" set {ftype, next} ({file type, name extension} of file mycurrentfile) if (ftype "pdf ") or (next "pdf") -- open mycurrentfile acrobat tell application "adobe acrobat pro" ... else -- open mycurrentfile else tell application "preview" ... end if
Comments
Post a Comment