使用applescript保存illustrator文件

使用applescript保存illustrator文件,applescript,adobe-illustrator,Applescript,Adobe Illustrator,我目前正在尝试自动化一个过程,即我获取一个.ai文件,将其保存到桌面,然后将所有文本更改为大纲,并将另一个副本保存到桌面,并在名称中添加_OL,例如 IN> server/elements.ai OUT> desktop/elements.ai & desktop/elements_OL.ai 多亏了Tim Joe,它现在保存了,但不会选择文本将其转换为大纲 如果有人能帮我,我会非常感激,我会在工作中一遍又一遍地重复同样的过程,让它自动化将是最好的 以下是我到目前为止得到的

我目前正在尝试自动化一个过程,即我获取一个.ai文件,将其保存到桌面,然后将所有文本更改为大纲,并将另一个副本保存到桌面,并在名称中添加_OL,例如

IN> server/elements.ai
OUT> desktop/elements.ai & desktop/elements_OL.ai
多亏了Tim Joe,它现在保存了,但不会选择文本将其转换为大纲

如果有人能帮我,我会非常感激,我会在工作中一遍又一遍地重复同样的过程,让它自动化将是最好的

以下是我到目前为止得到的(修改为包括保存选项、illustrator版本和文件路径为字符串)

 set saveLocation to ((path to desktop) as string) --place to save the files
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to (saveLocation & fileName) --file path of new .ai
set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines


tell application "Adobe Illustrator"
activate
open theFile without dialogs
save current document in file fullPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save file to desktop
selectobjectsonactiveartboard --select all
convert to paths --convert all text to outlines
display dialog "pause"
save current document in file olPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save another copy to desktop with name + _OL.ai 
quit
end tell

您可以获取到但不包括扩展名的完整路径,然后将
\u OL.ai
添加到该扩展名的末尾:

set olPath to text 1 thru ((length of fullPath) - 3) of fullPath & "_OL.ai"

请参阅底部的工作答案

我总是使用保存选项,所以这可能是原因

save theCurrentFile in file NewFileNamePath as as Illustrator ¬
                with options {class:Illustrator save options ¬
                , compatibility:Illustrator 15 ¬
                , font subset threshold:0.0 ¬
                , embed linked files:false ¬
                , save multiple art boards:false}
兼容性选项:Illustrator 10/Illustrator 11/Illustrator 12/Illustrator 13/Illustrator 14/Illustrator 15/Illustrator 3/Illustrator 8/Illustrator 9/Japanese 3--要创建的Illustrator文件格式版本(默认值:Illustrator 15)

更新:工作保存

set saveLocation to ((path to desktop) as string) --You were missing as string so it was making an array. The array adds "," making an invalid save location.
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to saveLocation & fileName --file path of new .ai
--set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines

log fullPath
tell application "Adobe Illustrator"
    activate
    open theFile without dialogs
    save current document in file fullPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:false, save multiple artboards:false}

end tell
简言之,缺少两件事:

  • 兼容性:Illustrator 15--必须有版本号,您是 错过了
  • 将saveLocation设置为((桌面路径)作为字符串)--需要 一串
享受:)

更新并使用以下内容:

    set saveLocation to ((path to desktop) as string) --place to save the files
set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
tell application "Finder" to set fileNameExention to name extension of theFile
set trimNumber to (((count fileNameExention) + 2) * -1) -- add two to include period and placment
set fileName to (characters 1 thru -4 of fileName) as string -- get just the file name with not extention
set fullPath to (saveLocation & fileName) --file path of new .ai
set VectorPath to fullPath & ".ai"
set olPath to fullPath & "_OL.ai" --file path of new .ai with outlines

tell application id "com.adobe.Illustrator"
    activate
    open theFile without dialogs
    save current document in file VectorPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save file to desktop
    convert to paths (every text frame of current document)
    display dialog "pause"
    save current document in file olPath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 15, font subset threshold:0.0, embed linked files:true, save multiple artboards:false} --save another copy to desktop with name + _OL.ai 
    quit
end tell

完成了!享受。

您所使用的人工智能版本是什么?它是Adobe Illustrator CS5.1,请参阅我的更新。当使用alias时,在更改它们时将其设置为字符串。我在上面看到的唯一问题是Illustrator 15需要在兼容性之后:在{}内部。你以前有过。保存行应如下所示:“将当前文档保存在文件olPath中作为Illustrator,选项{class:Illustrator保存选项,兼容性:Illustrator 15,字体子集阈值:0.0,嵌入链接文件:true,保存多个艺术板:false}”感谢您的帮助,现在正在保存,不幸的是,现在它正在保存,我已经了解到它不喜欢“全选”命令--,自从问了这个问题后,我就明白了这一部分,但无论如何,谢谢:)我想你可能也不知道illustrator文件为什么不保存?我尝试了一下,但现在我得到了一个错误“无法将一些数据转换为预期的类型”我不得不稍微修改一下你的代码,使其能够编译,并将修改后的代码放在我的问题中,我是否写错了什么?你需要一个兼容版本。Illustrator无效Illustrator 15有效。我会看看是否有其他东西我修正了路径,所以它是一个字符串,但在我把数字15放在illustrator之后,我得到了“枚举错误”。另外,15是否意味着CS5?Illustrator 15是Illustrator术语,只能在Illustrator块中定义。我能想到的唯一获得枚举错误的方法。你能把你的剧本的最新版本发上去吗。我的上一次更新是经过测试并正常工作的,但只做了第一次保存,即打开一个文件并保存一次。这是adobe的后端代码。17=CC 16=CS6 15=CS5/CS5.5,依此类推。因为你在CS5.1上,所以你想要15。我正在更新你需要的东西。今天早上有空。