如何使用 Applescript 在 Illustrator 中打开 Photoshop 项目?
How do I open Photoshop projects in Illustrator using Applescript?
我正在尝试编写一个脚本,它采用我在 photoshop 中编辑的多个项目并在 Illustrator 中打开它们,进行一些更改,以多种不同的方式保存它,然后关闭项目并打开下一个项目.除了在 Illustrator 中打开 photoshop 文件外,我一切正常。所有项目都将位于同一个文件夹中,因此我尝试使用查找器将所有这些文件设置为一个列表,然后在 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。这里的任何见解将不胜感激。一直在用头撞桌子试图解决这个问题。
您可以让 Finder 使用特定的应用程序打开文档。
请试试这个(保留打开的行注释掉)
tell application "Finder"
set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files"
end tell
activate application "Adobe Illustrator"
repeat with f in theFiles
tell application "Finder" to open f using application file id "com.adobe.illustrator"
tell application "Adobe Illustrator"
-- open f with options {class:Photoshop options, preserve hidden layers:true, preserve layers:true} 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"
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
…
我正在尝试编写一个脚本,它采用我在 photoshop 中编辑的多个项目并在 Illustrator 中打开它们,进行一些更改,以多种不同的方式保存它,然后关闭项目并打开下一个项目.除了在 Illustrator 中打开 photoshop 文件外,我一切正常。所有项目都将位于同一个文件夹中,因此我尝试使用查找器将所有这些文件设置为一个列表,然后在 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。这里的任何见解将不胜感激。一直在用头撞桌子试图解决这个问题。
您可以让 Finder 使用特定的应用程序打开文档。 请试试这个(保留打开的行注释掉)
tell application "Finder"
set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files"
end tell
activate application "Adobe Illustrator"
repeat with f in theFiles
tell application "Finder" to open f using application file id "com.adobe.illustrator"
tell application "Adobe Illustrator"
-- open f with options {class:Photoshop options, preserve hidden layers:true, preserve layers:true} 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"
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
…