Skip to main content
Participant
February 10, 2023
Question

Add different suffix to each exported file

  • February 10, 2023
  • 3 replies
  • 2928 views

I have wrote a script which outputs a single image multiple times.

Each either as a different file type or with differnt dimentions/dpi.

 

This works perfectly however I need it to also add a specific prefix to the files as it exports each out.

for example instead of 'filename.png' it would be 'filename_300dpi.png'

 

I will copy my script below and hope someone can help a noob scripter like me out.

 

I will mark up where I believe the new bits of script need to be added and what they should be

EXAMPLE

 

Thanks

 

on open AWOrig

 

tell application "Finder"

set f to (choose folder with prompt "Choose Render Folder")

 

set Jobno to display dialog "Name Output folder" default answer "OUTPUT"

set TRno to text returned of Jobno as text

 

set g to f as text

set jobfold to (g & TRno)

 

if exists folder jobfold then

display dialog "Job Folder Found. Current Files will be overwritten" buttons {"Overwrite", "Quit"}

if the button returned of the result is "Quit" then

error number -128 -- stops executing script

end if

 

else

make new folder at f with properties {name:TRno}

-- make new folder at jobfold with properties {name:"PNG"}

end if

 

 

end tell

 

tell application "Adobe Photoshop 2022"

 

set background color to {class:RGB color, red:255, green:255, blue:255}

 

repeat with AWDoc in AWOrig --Need to add is a repeat variable for multiple files

 

open AWDoc

 

set display dialogs to never --So there's no stops in the script, useful for batches

set docnm to name of current document --works out if it needs processing

 

 

tell current document

 

delete every path item

 

try

make art layer

merge visible layers

try

repeat

delete layer 2

end repeat

end try

end try

 

set docHeight to height --Setting the height & Width as variables

set docWidth to width --To be able to compare biggest value

 

if docWidth is greater than or equal to docHeight then

resize image width 3000 resolution 300

else

resize image height 3000 resolution 300

end if

 

resize canvas width 3000 height 3000 anchor position middle center

 

 

save in file f as JPEG with options {class:JPEG save options, embed color profile:true, format options:optimized, matte:background color matte, quality:12}

save in file f as TIFF with options {class:TIFF save options, image compression:LZW, transparency:true}

--save in file PNG_fold as PNG with options {class:PNG save options, compression:1}

save in file f

 

save in file f as PNG with options {class:PNG save options, compression:1}

SAVE with SUFFIX _300dpi

resize image width 1600

 

save in file f as JPEG with options {class:JPEG save options, embed color profile:true, format options:optimized, matte:background color matte, quality:12}

SAVE with SUFFIX _1600

resize image height 1500 resolution 150

 

save in file f as PNG with options {class:PNG save options, compression:1}

SAVE with SUFFIX _150dpi

resize image height 720 resolution 72

 

save in file f as PNG with options {class:PNG save options, compression:1}

SAVE with SUFFIX _72dpi

close without saving

 

end tell

 

 

 

end repeat

 

end tell

 

end open

This topic has been closed for replies.

3 replies

Rob_Cullen
Community Expert
Community Expert
February 14, 2023

Maybe off-topic, but Lightroom-Classic (if available to the OP) can do all of that without needing scripting.

File type- Yes

Dimensions- Yes

PPI- Yes

Filename change- Yes

Batch Export- Yes

Export Presets can set all these parameters, and then selecting multiple Presets you Export the multiple versions with one click of the mouse.

An example Preset-

 

Regards. My System: Windows-11, Lightroom-Classic 15.1.1, Photoshop 27.3.1, ACR 18.1.1, Lightroom 9.0, Lr-iOS 10.4.0, Bridge 16.0.2 .
Stephen Marsh
Community Expert
Community Expert
February 15, 2023

@Rob_Cullen – I’m sure that the Image Processor Pro script can also do this, it can save up to 10 different versions in one go with each having different resolutions, dimensions, filenames etc.

 

Lots of options, sadly none of them for AppleScript!

Stephen Marsh
Community Expert
Community Expert
February 11, 2023

Probably best that you try at;

 

https://www.macscripter.net

Stephen Marsh
Community Expert
Community Expert
February 10, 2023

Ah, AppleScript, not many regulars here appear to use that...

c.pfaffenbichler
Community Expert
Community Expert
February 11, 2023

@Stephen Marsh wrote:

Ah, AppleScript, not many regulars here appear to use that...


Indeed. 

 

@James_Needs Help , would you be open to doing Photoshop Scripting in JavaScript? 

As the platform independent option it is the most popular choice around here. 

Stephen Marsh
Community Expert
Community Expert
February 12, 2023

A middle-ground option... As AS can execute JS, it would be possible to have a hybrid Frankenscript that only used JS for naming/saving.