我已经在@chuck和其他主页帖子的帮助下整理了一份AppleScript,以便有效地批量打印从filemaker容器导出的文件列表到名为" print"在我的桌面上。
我现在遇到的问题是其中一些容器导出不是PDF(它是Jpg,PNG,Tif和PDF的混合)并且不会使用acrobat打开(使用PDF或任何其他预览) PDF查看器由于种种原因无法解决问题)...由于来自acrobat的错误消息必须在脚本进入下一个文件之前手动单击,因此该问题实际上会关闭工作流程。
我的问题是可以命令使用applescript来确定文件类型并选择一个不同的程序来打开文档并触发打印命令并关闭窗口,然后再移动到序列中的下一个文档。
(即如果.pdf然后使用acrobat打印关闭窗口,如果不使用预览打开文件,打印关闭窗口,重复直到所有文件都已打印。)
以下是我当前的工作代码。(FYI)此脚本在创建" Print"的文件制作器脚本中运行。桌面上的文件夹,并将容器字段导出到该文件夹。
`set myFolder to (path to desktop folder as text) & "Print:"
set myfiles to list folder myFolder without invisibles
repeat with myfile in myfiles
set mycurrentfile to ((myFolder as string) & (myfile as string)) as string
batchprint(mycurrentfile)
end repeat
on batchprint(mycurrentfile)
tell application "Adobe Acrobat Pro"
activate -- bring up acrobat
open alias mycurrentfile -- acrobat opens that 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" -- to move the printed file out
set x to ((path to desktop folder as text) & "Printed PDFs:")
if alias x exists then
beep
else
make new folder at the desktop with properties {name:"Printed PDFs"}
end if
move alias mycurrentfile to folder "Printed PDFs"
end tell
end batchprint`
答案 0 :(得分:3)
使用Finder测试文件类型和扩展名,然后使用Acrobat tell block(如果它是pdf),并使用Preview或其他任何内容(如果不是)。 这是代码结构:
tell application "Finder" to set {fType, nExt} to ({file type, name extension} of file mycurrentfile)
if (fType is "PDF ") or (nExt is "pdf") then
-- Open mycurrentfile with Acrobat
tell application "Adobe Acrobat Pro"
...
else
-- Open mycurrentfile with something else
tell application "Preview"
...
end if