【发布时间】:2020-12-27 09:33:51
【问题描述】:
我仍然处于 Automotor 和 AppleScript 学习曲线的底部,因此我很抱歉缺乏基本的理解,这不可避免地导致了这个问题。
我在 MacBook Air 上运行 MacOSX 10.15.6 (Catalina)。我的最终目标是获取一个包含 .pages 文件(或其他兼容文件类型)的文件夹,并通过使用 Pages 打开然后导出到与新文件类型相同的文件夹来批量转换为 .pdf(或其他)。我设置了一个 Automator 脚本,其中包含: 一世。 Get Specified Finder Items - 定义包含文件的文件夹 ii.获取文件夹内容 - 列出文件夹中的所有文档 iii. AppleScript 打开每个文档并导出为 PDF
甚至在到达“导出”位之前(我已经在下面的位中注释掉了导出命令),当我尝试获取包含文件的目录的路径时,AppleScript 会引发错误。 AppleScript 看起来像:
on run {input, parameters}
repeat with theFile in input
tell application "Pages"
set theDoc to open theFile
set theDocName to name of theDoc
set theName to (characters 1 thru -7 of theDocName) as text
set thePDFPath to ((path to theFile as text) & theName & ".pdf") as text
-- export theDoc to thePDFPath as PDF
close theDoc
end tell
end repeat
end run
我得到的错误是:
“运行 AppleScript”操作遇到错误:“Pages got an 错误:无法将别名“path:to:directory:test.pages”转换为类型 不变。”
我已经为此苦苦挣扎了一段时间,到目前为止我在网上找到的任何建议都没有帮助解决这个问题。任何帮助将不胜感激。
【问题讨论】:
标签: applescript automator