AppleScript 将拖动的文档传递给另一个应用程序

AppleScript to pass dragged document to another application

感谢 ,我的 Mac 有一点 AppleScript 可以打开 Adob​​e Distiller 的新会话。

do shell script "open -n -a " & quoted form of "Acrobat Distiller"

新问题,要求对此进行小的改进。难道如果一个.ps被拖(或者实际上,被拖了几个)到这个.scpt制作的.app中,Distiller的新会话会打开那个文件(或那几个文件)?

谢谢。

将以下脚本保存为应用程序。如果您 运行 该应用程序,它会让您选择要在新实例中打开的文件;如果你把文件放在上面,它会在一个新的实例中打开它们:

on run
    set filesToOpen to choose file with multiple selections allowed
    set fileListString to createUnixFileString(filesToOpen)
    makeNewInstanceWithFiles(fileListString)
end run

on open droppedFiles
    set fileListString to createUnixFileString(droppedFiles)
    makeNewInstanceWithFiles(fileListString)
end open

on createUnixFileString(aList)
    set fileString to ""
    repeat with thisItem in aList
        set fileString to fileString & " " & quoted form of (POSIX path of thisItem)
    end repeat
    return fileString
end createUnixFileString

on makeNewInstanceWithFiles(f)
    do shell script "open -n -a " & quoted form of "Acrobat Distiller" & f
end makeNewInstanceWithFiles

如果您希望每个文件在单独的实例中打开,请为每个文件调用 makeNewInstanceWithFiles(确保获取 posix 路径并包含 space 作为分隔符)调用 createUnixFileString 处理程序。