January 31, 2007

Useful Photoshop layer-handling scripts

Last week Ralf Berger, co-creator of Photoshop’s Vanishing Point tool (and formerly eng. manager for LiveMotion), asked me whether Photoshop offered a way to clean up files by deleting empty layers.  I knew that the Layers palette fly-out menu contains a command to delete hidden layers, but not one for blowing away those with no pixel content.  After a nudge towards the Photoshop JavaScript guide (installed in the application folder, btw), Ralf whipped up this script for deleting blank layers.  I’m posting it here in case it’s useful. (You may want to right-click/Ctrl-click the link to download the script, then put the file into your Photoshop folder under Presets/Scripts.)

On a related note,
I came across a Trevor Morris’s trove of handy-looking little scripts.  And for more PS scriptiness, including a good discussion forum, check out PS-Scripts.com.

Posted by John Nack at 12:44 AM on January 31, 2007


  • Patrik — 4:56 PM on February 07, 2007

    Hi John,
    Thanks for the script. I had written a similar thing in Applescript but I am sure the javascript will run faster.
    Do you have any similar scripts that allow me to copy a warp from one smart object to another. Or a script that makes layer comps based on prefixes.
    [Patrik, I don’t have anything myself, but you should definitely try the Photoshop scripting forum, Adobe Exchange, and similar resources. –J.]
    I do a lot of versioning in my office and am often faced with having to make prototypes before the items exist. I make them out of press ready files and a photoshoot of a blank book. Therefore my need of copying warps. So that I can do 15 languages at once. Also any idea on automatic generation of layer comps based on a prefix and set background and foreground layers that are always on.
    Best, Patrik

  • Troy — 11:49 AM on March 05, 2007

    Thanks, John, that’s exactly what I was looking for. Checking out the source code for it I feel kinda stupid for even searching… I didn’t even think to simply test the bounds of the layer to determine if it was empty (shows how often I do PS scripting).
    I did notice that its surprisingly slow. I’ve got a bunch of PSD’s that have a few hundred layers each (of which 90% are empty due to some limited PSD export from an animation package we’re using) and its taking around 10 minutes to delete all the empty layers in one file (the PSD is 256×256 in size). This surprises me… does it match the speed you’re seeing?
    [Hmm–that does sound slow. Let me inquire with the team. Thanks for the heads-up. –J.]

  • Alex — 6:41 AM on March 13, 2007

    WOW! This is great! Thank you. This is the kind of thing I love.

  • Aaron — 12:00 PM on April 03, 2007

    Was wondering if anyone had any advice. I used Trevor Morris’s Search For Layers Script. Works but only searches layers that are “not” in a folder. Any feedback to what I need to change in the script to search for layers that are inside folders?

  • Moritz — 7:46 AM on November 04, 2008

    Hi John
    how do I install this script?
    Thanks in advance..
    [Just download the file to your hard drive, then copy it and move it to your Adobe Photoshop CS3(4)/Presets/Scripts folder. When you launch PS the script will appear under the File->Scripts menu. –J.]

  • Nate — 12:45 PM on July 19, 2009

    Well, sadly this would be a wonderful script if it did more then crash cs4… =/ Not sure whats going on…

  • Carson — 5:01 AM on August 17, 2010

    Same question I had for the script about removing ‘copy’ from all layers, will this work in CS5?

    • Jeffrey Tranberry — 8:34 AM on August 17, 2010

      The script to remove copy should work in CS5 just fine.

      • Meagan — 9:48 AM on April 11, 2011

        Is there a script that will remove all layers that aren’t being used in your layer comps?

  • Jeroen — 5:33 AM on February 02, 2011

    Very nice script! thanks you very much!

    Is there also a script available to delete all layers that are not used in the Layer Comps you have made.


    • Rasmus Keldorff — 1:09 AM on April 01, 2011

      Looking for this exact thing myself — a way to purge layers unused in any Layer Comp.

      Oh, and while we’re at it: a Search functionality (find layer by name). Really.

  • Alexander Hahn — 3:56 AM on May 10, 2011

    Is there a script that will remove all layers that aren’t being used in your layer comps? would e so great to clean large files!

Copyright © 2020 Adobe Systems Incorporated. All rights reserved.
Terms of Use | Privacy Policy and Cookies (Updated)