skip to Main Content

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


  1. You can tell the Finder to open a document with a specific application.
    Please try this (keep the open line commented out)

    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
    …
    
    Login or Signup to reply.
  2. does this work

    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
    …
    
    Login or Signup to reply.
  3. last try

    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
    
     …
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search