Skip to content

Instantly share code, notes, and snippets.

@joonaspaakko
Created August 12, 2016 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonaspaakko/d3c8e4273271433bf2f90835bf65c172 to your computer and use it in GitHub Desktop.
Save joonaspaakko/d3c8e4273271433bf2f90835bf65c172 to your computer and use it in GitHub Desktop.
var doc = app.activeDocument;
doc.suspendHistory("Remove Normal Layers", "deletePixelLayers( doc )");
function deletePixelLayers(target)
{
try{
var layers = target.layers;
for (var i = 0; i < layers.length; i++)
{
var curLayer = layers[i];
// Layer is a group
if ("LayerSet" == curLayer.typename) {
deletePixelLayers(curLayer);
}
// Layer is a NORMAL (Pixel) Layers
if (LayerKind.NORMAL == curLayer.kind
&& !curLayer.isBackgroundLayer) {
curLayer.remove(); // Delete the layer
--i;
};
};
}catch(e){
; // do nothing
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment