Skip to main content
Participant
May 5, 2009
Question

Export letters as separate files

  • May 5, 2009
  • 1 reply
  • 1407 views

I'm working on a touchscreen interface, which includes a keyboard, and rather than modify and export each letter individually everytime I want to change the font or the style, I'd like to have a script do it for me. Basically it would open the file, replace the text content by a letter/number picked from a pre-defined set (while keeping layer styles intact) and then save for web.

This could also be useful when you need dropcaps or you want to use images instead of letters or numbers on a website.

It seems like a pretty common task so I was wondering if there's any script out there that already does it. If not, how hard do you think it would be to do ? I'm a newb to photoshop scripting but I know photoshop well, as well as javascript, so it shouldn't be too hard right ?

Thanks for the help !

This topic has been closed for replies.

1 reply

Inspiring
May 6, 2009

Sounds like a job for Datasets. Search PS Help.

Participant
May 7, 2009

Thanks, I'll look into this. Actually I already succeeded in writing a script that does what I want, here it is:

var charArray=new Array(".","_","-",",","@","/","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0")
var namesArray=new Array("dot","underscore","dash","coma","at","slash","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0")


// Open file key.psd
var fileRef = File("myFile.psd")
var docRef = app.open(fileRef)
// Get character layer
var charLayerRef=app.activeDocument.artLayers.getByName("character")
// Set the contents of the text layer.
var textItemRef = charLayerRef.textItem
for(i=0;i<=charArray.length-1;i++){


textItemRef.contents = charArray

pngFile = new File( "/namesArray.png" )
app.activeDocument.saveAs(pngFile)

}

But I get an error 8080 with the saveAs function. In the end I just used the ScriptingListener plugin to record the code for "save as web" and this works fine, but I still wonder why the saveAs code (copied from the manual) doesn't work...

Inspiring
May 7, 2009

It works, thanks ! I don't know what that 8080 error means, but in any case it went away thanks to your code.


8080 (and 8800) are generic error codes that PS uses when it can't tell you anything specific about what went wrong.