Skip to main content
November 3, 2011
Answered

Delete unused layer..?

  • November 3, 2011
  • 3 replies
  • 7863 views

Hi Everyone!,

I am new baby to indesign scripting and anyone to help me find that below indesign script.

How do i delete unused layer in indesign CS4? and how do know linked image mode like CMYK, RGB, LAB.

Thanks in Advance.

- yajiv

This topic has been closed for replies.
Correct answer Harbs.

This should remove empty layers:

var layers = app.documents[0].layers.everyItem().getElements();

for(var i=layers.length-1;i>=0;i--){

  if(layers.pageItems.length==0){

    layers.remove();

  }

}

3 replies

Harbs.
Brainiac
November 3, 2011

place a single image in an empty doc, and this will give you the color space:

alert (app.documents[0].pageItems[0].images[0].space);

Harbs

November 3, 2011

Hi Harbs!

Thanks for you reply.

I used your above script, slightlty modify and Its work fine.

Here th modify code...

var layers = app.activeDocument.layers.everyItem().getElements();

for(var i=layers.length-1;i>=0;i--){

  if(layers.pageItems.length==0){

    layers.remove();

  }

}

Thank you very much....

-yajiv

Harbs.
Brainiac
November 3, 2011

The problem was a capital L in getElements()...

Harbs.
Harbs.Correct answer
Brainiac
November 3, 2011

This should remove empty layers:

var layers = app.documents[0].layers.everyItem().getElements();

for(var i=layers.length-1;i>=0;i--){

  if(layers.pageItems.length==0){

    layers.remove();

  }

}

Colin Flashman
Community Expert
November 3, 2011

i know of one which only gets rid of invisible layers which can be found at:

http://objectmix.com/adobe-indesign/239660-how-delete-invisible-layers-inindesign-cs2-file-using-javascript.html

alternatively, google the script "inwash.jsx" by vitaly batushev

in terms of finding out if a linked image is CMYK, RGB, LAB etc, this can be done from the links panel itself from CS4 and up. If you can't see it at the moment, go to the panel options within the links panel and select  the following:

this is only really useful for rasters such as tiffs, jpgs etc. it won't advise if a PDF contains RGB, CMYK etc for example.

i know it's not what the OP was hoping for, but hope it helps

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
November 3, 2011

Hi cdflash!,

Thanks for your kind reply. Actualy i need to delete unused layer (ie. There is no link image include in that layer).

I'm try to write script but i can't. I know that Color Space in Pannel option. Some time i forget saw that option.

that's why i need that script.

-yajiv