AppleScript的到(如果/那么)判断文件类型,并选择正确的程序打开和打印文件(批处理序列内) [英] Applescript to (if/then) determine file type and choose correct program to open and print file (within batch sequence)

查看:969
本文介绍了AppleScript的到(如果/那么)判断文件类型,并选择正确的程序打开和打印文件(批处理序列内)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经扑杀连同@chuck很大的帮助和其他板帖子的AppleScript有效地批量打印从容器的FileMaker导出到一个名为打印在我的桌面文件夹中的文件列表。

I have culled together an applescript with great help from @chuck and other board posts to effectively batch print a list of files exported from filemaker containers to a folder called "print" on my desktop.

我运行到现在的问题是,一些人集装箱出口都不是PDF,将无法打开使用Acrobat(其JPG,PNG,TIF和PDF的混合)(使用preVIEW为PDF或任何其他的PDF阅读器是出去的原因,无数的问题)的...这个问题是有效地关闭,因为从Acrobat的错误信息,必须在脚本将继续下一个文件之前,可以手动挂断的工作流程。

The problem I'm running into now is some of those container exports are not PDF (its a mix of Jpg, PNG, Tif and PDF) and will not open using acrobat (using preview for the PDF or any other PDF viewer is out of the question for a myriad of reasons)... This problem is effectively shutting down the work flow because of error messages from acrobat that must be manually clicked off before the script will proceed to the next file.

我的问题是可以的AppleScript被命令确定文件类型第一,选择不同的程序移动到序列中的下一个文档之前打开的文档,并触发打印命令并关闭窗口。

My question is can applescript be commanded to determine the file type first and choose a different program to open the document with and trigger the print command and close window before moving onto the next document in the sequence.

(即,如果.PDF然后使用Acrobat打印关闭窗口,如果不使用preVIEW打开文件,打印关闭窗口,重复,直到所有文件已被打印出来。)

(i.e. if .pdf then use acrobat print close window, if not use preview to open file, print close window, repeat until all files have been printed.)

下面是我当前的工作code (FYI)这个脚本是创建桌面上的打印文件夹,并导出容器字段的文件夹的FileMaker脚本中运行。

Below is my current working code.(FYI) This script is running within a filemaker script that is creating the "Print" folder on the desktop and exporting the container fields to the folder.

`set myFolder to (path to desktop folder as text) & "Print:"

设置myfiles的名单没有隐身MyFolder文件夹

重复与myfiles的MYFILE

set mycurrentfile to ((myFolder as string) & (myfile as string)) as string
batchprint(mycurrentfile)

结束重复

上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

结束batchprint`

end batchprint`

推荐答案

使用Finder来测试文件类型和扩展名,然后用你的Acrobat告诉块,如果它是一个PDF格式,并使用preVIEW或什么,如果它不是。
这里的code结构是:

Use Finder to test for the file type and the extension, then use your Acrobat tell block if it's a pdf, and use Preview or whatever if it is not. Here's the code structure for that:

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

这篇关于AppleScript的到(如果/那么)判断文件类型,并选择正确的程序打开和打印文件(批处理序列内)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆