Apple Script 应该如何自动打开下载到 Downloads 文件夹的名为 testfile 的文件并使用程序 testprogram 运行?
我觉得它应该是一个非常简单的模板,我很难找到很多东西来完成它。
Apple Script 应该如何自动打开下载到 Downloads 文件夹的名为 testfile 的文件并使用程序 testprogram 运行?
我觉得它应该是一个非常简单的模板,我很难找到很多东西来完成它。
此示例使用 Microsoft Word 打开 testFile.rtf。使用您的信息更新代码并将文件夹操作附加到您的目标文件夹。
on adding folder items to theFolder after receiving theFiles
set appPath to quoted form of (POSIX path of (path to applications folder) & "Microsoft Office 2011/Microsoft Word.app")
repeat with aFile in theFiles
tell application "Finder" to aFile's name = "testfile.rtf"
if the result then
set filePath to quoted form of aFile's POSIX path
do shell script "open -a " & appPath & space & filePath
end if
end repeat
end adding folder items to
如果您要手动打开文件,请尝试以下操作:
set appPath to quoted form of (POSIX path of (path to applications folder) & "Microsoft Office 2011/Microsoft Word.app")
set filePath to quoted form of (POSIX path of (path to documents folder) & "testFile.rtf")
try
do shell script "open -a " & appPath & space & filePath
end try
您可以使用 Automator 创建这样的文件夹操作:
Finder 的open
命令还有一个using
用于指定应用程序的说明符:
tell application "Finder"
open POSIX file "/usr/share/doc/bash/bash.html" using (path to application "Safari")
end tell