使用applescript保存illustrator文件

时间:2014-05-01 09:53:25

标签: applescript adobe-illustrator

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

IN> server/elements.ai
OUT> desktop/elements.ai & desktop/elements_OL.ai

感谢蒂姆乔现在保存,但它不会选择文本将其转换为轮廓。

如果有人可以帮助我,我会非常感激,我会在工作中一遍又一遍地做同样的过程,让它自动化是最好的。

这是我到目前为止所做的(修订为包含保存选项,插图版本和文件路径为字符串)

 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

2 个答案:

答案 0 :(得分:1)

您可以获得fullPath,但不包括扩展名,然后将_OL.ai添加到该末尾:

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

答案 1 :(得分:1)

请参阅底部以了解工作答案!

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

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 /日语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

完成!享受。