【发布时间】:2021-11-12 16:19:28
【问题描述】:
当使用 Automator 将其添加到我的文件夹中时,我正在尝试重命名名为“Invoice Template.pdf”的查找器项目。但是,每次脚本运行时,我都会收到 Finder 出现错误:无法将文件“Invoice Template.pdf”设置为“Invoice 11.08.2021.pdf”。任何想法为什么?
tell application "Finder"
set dateObj to (current date)
set theMonth to text -1 thru -2 of ("0" & (month of dateObj as number))
set theDay to text -1 thru -2 of ("0" & day of dateObj)
set theYear to year of dateObj
set dateStamp to "" & theMonth & "." & theDay & "." & theYear
set theFile to "DBF Invoice Template.pdf"
set theName to "Invoice"
set the name of file theFile to theName & " " & dateStamp & ".pdf"
end tell
【问题讨论】:
-
您应该将您的 pdf 文件的完整 HFS 路径分配给 File 变量。
-
在您的问题中,您提到了 Automator。 Automator 与此有什么关系?当您使用 Automator 将其添加到我的文件夹时说“Invoice Template.pdf”时,这是您在 Automator 中创建的 Folder Action 场景吗?
-
@user3439894 是的。很抱歉我忘了提及这一点。
标签: applescript