【问题标题】:Applescript throws error when changing file name更改文件名时Applescript引发错误
【发布时间】:2019-07-14 17:18:48
【问题描述】:

我正在尝试创建一个通用临时 .pdf,然后使用以下代码将临时文件的文件名更改为 NAS 驱动器上同一文件夹中的特定文件名。

我收到错误 -10006 'can't change name of file..."。任何帮助将不胜感激。


tell application "Microsoft Excel"
save active workbook in ("Volumes:FrameNASfolder:12 PANDORA:Pandora PDFs:PDF
    TempFolder:TempName.pdf") as PDF file format
end tell

tell application "Finder"
set name of "Volumes:FrameNASfolder:12 PANDORA:Pandora PDFs:PDF
 TempFolder:TempName Invoice + Quotation Sheet.pdf" to "3999A Estimate TEST 14-07-20 16-32.pdf"
end tell

我每次都可以生成临时文件,但更改名称并不快乐。

【问题讨论】:

  • 您正在尝试更改 string 的名称 - 尝试使用 file

标签: file applescript


【解决方案1】:

首先——即使 伪 POSIX 语法有效——HFS 路径应该以磁盘名称开头,而不是 UsersVolumes

如 cmets 中所述,您将更改字符串的文件名,这毫无意义。添加关键字fileitemalias 以创建文件系统引用

set tempFolderPath to "FrameNASfolder:12 PANDORA:Pandora PDFs:PDF TempFolder:"

tell application "Microsoft Excel"
    save active workbook in (tempFolderPath & "TempName.pdf") as PDF file format
end tell

tell application "Finder"
    set name of file (tempFolderPath & "TempName Invoice + Quotation Sheet.pdf") to "3999A Estimate TEST 14-07-20 16-32.pdf"
end tell

【讨论】:

    猜你喜欢
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-09
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多