I’m trying to write a script that takes multiple projects I have edited in photoshop and opens them in Illustrator, makes some changes, saves it a bunch of different ways, and then closes the project and opens the next one. I have everything working except opening the photoshop files in Illustrator. All the projects will be located in the same folder so I tried setting all those files to a list using the finder and then in illustrator opening the file. Here is the code:
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
Currently this code opens the file in photoshop and not in Illustrator which really confuses me since I’m telling the Illustrator application to open it, not the finder. Any insight here would be much appreciated. Been banging my head against my desk trying to figure this one out.
3
Answers
You can tell the Finder to open a document with a specific application.
Please try this (keep the open line commented out)
does this work
last try