Scripting 如何使用Applescript在Illustrator中打开Photoshop项目?

Scripting 如何使用Applescript在Illustrator中打开Photoshop项目?,scripting,applescript,Scripting,Applescript,我正在尝试编写一个脚本,它包含我在photoshop中编辑的多个项目,并在Illustrator中打开它们,进行一些更改,以多种不同的方式保存,然后关闭项目并打开下一个项目。除了在Illustrator中打开photoshop文件外,我的一切都正常工作。所有的项目都将位于同一个文件夹中,所以我尝试使用finder将所有这些文件设置为列表,然后在illustrator中打开文件。代码如下: tell application "Finder" set theFiles to files of

我正在尝试编写一个脚本,它包含我在photoshop中编辑的多个项目,并在Illustrator中打开它们,进行一些更改,以多种不同的方式保存,然后关闭项目并打开下一个项目。除了在Illustrator中打开photoshop文件外,我的一切都正常工作。所有的项目都将位于同一个文件夹中,所以我尝试使用finder将所有这些文件设置为列表,然后在illustrator中打开文件。代码如下:

tell application "Finder"
    set theFiles to files of folder POSIX file "/Volumes/Assets/BLG.com Images/Images for Renaming/Photoshop Files" as list
end tell
repeat with f in theFiles
    tell application "Adobe Illustrator"
        activate
        open f with options {class:Photoshop options, preserve hidden layers:true, preserve layers:true} without dialogs
        set allLayers to layers of document 1
        set allImages to page items of document 1
        repeat with lay in allLayers
            set visible of lay to true
        end repeat
        repeat with img in allImages
            set scaleMatrix to get scale matrix horizontal scale 416 vertical scale 416
            transform img using scaleMatrix
        end repeat
        selectobjectsonactiveartboard document 1
        delay 2
        do script "Fit Artboard to Selected" from "Fit Artboard"
        set visible of layer 2 of document 1 to false
        set visible of layer 4 of document 1 to false
        delay 2
        do script "Raw Copper Save" from "RC"
        set visible of layer 5 of document 1 to false
        delay 2
        do script "Architectural Copper Save" from "AR"
        set visible of layer 6 of document 1 to false
        delay 2
        do script "Satin Antique Save" from "SA"
        set visible of layer 7 of document 1 to false
        delay 2
        do script "Brushed Nickel Save" from "BN"
        set visible of layer 8 of document 1 to false
        delay 2
        do script "Polished Nickel Save" from "PN"
        set visible of layer 10 of document 1 to false
        set visible of layer 9 of document 1 to false
        delay 2
        do script "Antique Copper Save" from "AC"
        set visible of layer 11 of document 1 to false
        delay 2
        do script "Verdigris Patina Save" from "VG"
        set visible of layer 12 of document 1 to false
        delay 2
        do script "Satin Verdigris Patina Save" from "SV"
        set visible of layer 13 of document 1 to false
        set visible of layer 2 of document 1 to true
        delay 2
        do script "Black Save" from "BK"
        set visible of layer 14 of document 1 to false
        set visible of layer 2 of document 1 to false
        set visible of layer 15 of document 1 to false
        delay 2
        do script "Default Save" from "Default"
        delay 2
        save document 1 in "/Volumes/Assets/BLG.com Images/Images for Renaming/Illustrator Files" as Illustrator
        delay 2
        close document 1
    end tell
end repeat

目前,这段代码在photoshop而不是Illustrator中打开文件,这让我很困惑,因为我告诉Illustrator应用程序打开它,而不是finder。如果您有任何见解,我们将不胜感激。我的头撞在桌子上,想弄明白这一点。

你可以告诉查找者用特定的应用程序打开文档。 请尝试此操作(保留已注释的开放行)

这有用吗

tell application "Finder"
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" as alias list
end tell
tell application "Adobe Illustrator"
    activate
    tell Photoshop file options of settings
        set preserve hidden layers to true
        set preserve layers to true
    end tell
end tell
repeat with f in theFiles
    tell application "Adobe Illustrator"
        open f without dialogs
        set allLayers to layers of document 1
…
最后一次尝试

tell application "Finder"
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" as alias list
end tell
tell application "Adobe Illustrator"
    set user interaction level to never interact
    activate
    set photoshopOptions to {class:Photoshop options, preserve layers:true, preserve hidden layers:true}
    set IllustratorPreferences to {class:Illustrator preferences, Photoshop file options:photoshopOptions}
end tell
repeat with f in theFiles
    tell application "Adobe Illustrator"
        open f without dialogs
        set allLayers to layers of document 1

 …

这将在illustrator中打开文件,但我之所以使用该打开命令,是因为我需要在程序中保留层,而这些是我需要的选项。我希望它在打开每个文件时运行,而不给我弹出窗口,因为我不想在脚本运行时监视它。导入选项仍然弹出。我觉得很难相信没有什么方法可以自动化,但我想这可能是你必须点击的东西。谢谢你的帮助!非常感谢!没关系,这行得通!只需确保在Illustrator上进行硬重启,以便进行首选项更改。
tell application "Finder"
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" as alias list
end tell
tell application "Adobe Illustrator"
    set user interaction level to never interact
    activate
    set photoshopOptions to {class:Photoshop options, preserve layers:true, preserve hidden layers:true}
    set IllustratorPreferences to {class:Illustrator preferences, Photoshop file options:photoshopOptions}
end tell
repeat with f in theFiles
    tell application "Adobe Illustrator"
        open f without dialogs
        set allLayers to layers of document 1

 …