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.
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
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.]
WOW! This is great! Thank you. This is the kind of thing I love.
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?
Hi John
how do I install this script?
Thanks in advance..
mo
[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.]
Well, sadly this would be a wonderful script if it did more then crash cs4… =/ Not sure whats going on…
Same question I had for the script about removing ‘copy’ from all layers, will this work in CS5?
The script to remove copy should work in CS5 just fine.
Is there a script that will remove all layers that aren’t being used in your layer comps?
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.
Thanks
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.
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!