Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe Photoshop rename multiple layers automatically

  • rename multiple layers automatically

    Posted by Ellen Osborne on March 24, 2013 at 8:45 pm

    Hi
    I’ve imported an animation from After Effects into Photoshop. When I first imported it there were about 189 layers. I’ve eliminated about two thirds of these layers, which were scattered throughout the document. Now the naming on my layers is no longer consecutive. I’d like to rename the remaining layers consecutively starting with “Layer 1” followed by “Layer 2”, etc. I do not want to change the current order. Is there some kind of automatic way to do this? Or do I just need to do it manually?
    Thanks for the help.
    Ellen

    Ellen Osborne replied 13 years, 1 month ago 2 Members · 7 Replies
  • 7 Replies
  • Dwayne Smith

    March 24, 2013 at 11:52 pm

    G’day

    You could do it with a script.
    Here’s one that will work on a Mac — you’d just need to update the version number in the first line.
    Copy and paste the script into AppleScript Editor (probably in Applications > Utilities).
    Then click the run button (making sure your PS document is open and frontmost)

    tell application "Adobe Photoshop CS5"
    tell document 1
    set mgCountLayers to count layers
    set mgCount to 1
    repeat with mgLayer from mgCountLayers to 1 by -1
    set name of layer mgLayer to ("Layer " & mgCount)
    set mgCount to mgCount + 1
    end repeat
    end tell
    end tell

    d.

  • Ellen Osborne

    March 25, 2013 at 10:14 pm

    Thank you for this. I tried the above. I have my document open. I’m not sure what “frontmost” means. I click “run” but I get the following error “error “Adobe Photoshop CS6 got an error: The requested action requires that the target document is the frontmost document.” number 8100″

  • Ellen Osborne

    March 25, 2013 at 10:49 pm

    I figured it out the foremost thing. The script worked almost perfectly except it gave the Layer that I wanted to start as Layer 1 (the top layer in the stack) the highest number and then labeled the rest in a descending order. Anyway to get it to start at the top with layer 1?

  • Dwayne Smith

    March 25, 2013 at 10:55 pm

    HA — I knew I’d get it exactly wrong.

    In that case you need a simpler script :

    tell application "Adobe Photoshop CS6"
    tell document 1
    set mgCountLayers to count layers
    repeat with mgLayer from 1 to mgCountLayers
    set name of layer mgLayer to ("Layer " & mgLayer)
    end repeat
    end tell
    end tell

    Have a good one

    d.

  • Ellen Osborne

    March 25, 2013 at 10:59 pm

    Ok. I know we must almost be there, but now I get this error

    error “The variable amp is not defined.” number -2753 from “amp”

  • Dwayne Smith

    March 25, 2013 at 11:31 pm

    Have a look in applescript editor for the line it’s failing on (should be highlighted after you get the error).
    There’s no place the script is asking for the variable “amp” — so I expect there’s something incorrect in your compiled script.
    Make sure the compiled script matches the one posted.

    d.

  • Ellen Osborne

    March 26, 2013 at 12:07 am

    Copied and pasted it in again and it worked perfectly! Thanks so much!!!!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy