skip to Main Content

I have 1000s of psd file to change top layers as file name. Please help me to crate a script for this.

I want to have a JS-Script, which changes the Text of the Top Layer as file name.

For example: the file name is "20.psd",
the script should change the top layer as 20,

After that, it should save the file as png with same file name.

2

Answers


  1. Opening your example document 20.psd, will rename the topmost layer 20.psd
    You’ll be wanting to remove the extension. There are various ways of doing it.
    Like this.

    The JavaScript (Photoshop uses the extension .jsx) is quite straight forward.

    // call the source document
    var srcDoc = app.activeDocument;
    
    // Get the name of the psd document
    var docName = app.activeDocument.name;
    
    // Deal with the extension
    // Trim of the last four characters
    // ie ".psd"
    docName = docName.slice(0, -4);
    
    
    // Rename layer the topmost text layer
    srcDoc.layers[0].textItem.contents = docName;
    

    If the topmost layer is a group, it’ll rename that. But I’m sure you can fix this.

    Login or Signup to reply.
  2. var origDoc = app.activeDocument;
    
    // duplicate the Document with new name
    origDoc.duplicate((origDoc.layers[0].textItem.contents), false); 
    
    // close previous one
    origDoc.close(SaveOptions.DONOTSAVECHANGES); 
    // (SaveOptions.SAVECHANGES);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search