nebneb2000
nebneb2000

Reputation: 29

Exporting PNGs from Photoshop using Apple Scripts

I am trying to do mass exporting of PNGs from Photoshop, and to do this, I am trying to use Apple Scripts. However, I cannot get it to export a PNG.

This is the current script that I'm using:

tell application "Adobe Photoshop 2024"

    activate

    open alias "Macintosh HD:Users:Ben:Downloads:Venue_Social_Media_Post_Template.psd"

    set theDoc to the current document

    set allLayerSets to every layer set of theDoc

    set layerFound to false

    repeat with aGroup from 1 to the count of allLayerSets

        set currentGroup to item aGroup of allLayerSets

        if name of currentGroup is "Event Details" then

            set allLayers to every art layer of currentGroup

            repeat with aLayer from 1 to the count of allLayers

                set currentLayer to item aLayer of allLayers

                if name of currentLayer is "Date" then

                    set layerFound to true

                    tell currentLayer to set the contents of the text object to "{date}"

                else if name of currentLayer is "Venue Name" then

                    set layerFound to true

                    tell currentLayer to set the contents of the text object to "{venue_name}"

                else if name of currentLayer is "Venue Location" then

                    set layerFound to true

                    tell currentLayer to set the contents of the text object to "{venue_city}, {venue_state}"

                else if name of currentLayer is "Time" then

                    set layerFound to true

                    tell currentLayer to set the contents of the text object to "{time}"

                end if

            end repeat

            if layerFound then

                -- Assuming the path and file name do not need quotes in AppleScript

                set outputPath to "Macintosh HD:Users:Ben:Downloads:" & "{venue_name}" & ".png"

                -- Directly save as PNG (this part may need to be adjusted for Photoshop 2024)

                export as save for web in file (Downloads & "Test.png") with options {{class:save for web export options, web format:PNG}}

                close theDoc saving no

                exit repeat

            end if

        end if

    end repeat

    if not layerFound then log "No layers found with the specified names."

end tell

I have gotten many errors but the current one is: Key Error: 'class'

Thanks in advance!

Upvotes: 0

Views: 75

Answers (0)

Related Questions