I used to use this script up last year to work with CS and OS10.3.9, and it does not work properly now with CS2 and 10.4. Can anyone help?
This script should place individual names on an open photoshop file and save the files to the desktop will different filenames, but what it does is constantly overwrite the one file.
And for some reason it chooses Myriad as the font?
set mystring to “Marcus Welby
James Coventry”
tell application “Adobe Photoshop CS2”
set the_layer to make art layer in current document with properties {kind:text layer, name:“Name Layer”}
tell text object of the_layer
set fontname to “Copperplate”
set stroke color to {class:RGB color, blue:255.0, green:255.0, red:255.0}
set size to 24
set justification to center
set position to {1500, 1475}
end tell
repeat with i from 1 to (count of paragraphs of mystring)
set eachName to text of paragraph i of mystring
set contents of text object of the_layer to eachName
set the_num to i
if the_num < 10 then set the_num to “0” & (i as string) save document 1 in ((((path to desktop) as string) & (the_num as string) & “.jpg”) as file specification) as JPEG with options {class:JPEG save options, quality:12} with copying end repeat end tell
OK, I think I solved it myself, but i don’t know what I did to fix it, I suppose dropping the sequential numbering helped, can anyone fix the initial code, or explain why it failed and this does not?
Here is the code that works…
set mystring to “FABAL
Ferrari Formalwear”
tell application “Adobe Photoshop CS2”
set the_layer to make art layer in current document with properties {kind:text layer, name:“Name Layer”}
tell text object of the_layer
set fontname to “Copperplate”
set stroke color to {class:RGB color, blue:255, green:255, red:255}
set size to 24
set justification to center
set position to {1500, 1475}
set ThePath to path to desktop
end tell
repeat with eachName in (paragraphs of mystring)
set eachName to text of eachName
set contents of text object of the_layer to eachName
save document 1 in file ((ThePath & eachName & “.jpg”) as string) as JPEG with options {class:JPEG save options, quality:12} with copying
end repeat
end tell
Its an old question, but the reason it does not work (I believe) is that Photoshop, other Adobe apps, and probably all apps, can’t do “Finder” things in the middle of a direct action they are doing, especially save actions. You can’t “get” {path to desktop) as string} in the middle of a save statement. You have to get it first, set it as a variable, then just use the direct variable in the save statement.
-Chris
SuperMacguy, you can if you use “tell application “Finder”” statements. (Just make sure to script it so that if it doesn’t find what it is looking for, or can’t do what it is trying to do, that you leave some sort of way out - either a message specifying that you can’t, or a catch incase it finds nothing. (Part of the problem I was having with another script was inserting the same statement without inserting a failsafe - not the brightest thing I’ve done!)