Delete all empty layers except one?

Hello

This script deletes all layers of empty/white. I need to delete all empty/white layers with the exception of the layer named "grid."

I tried searching the forum for some clues, but I'm stumped. Any help would be greatly appreciated.

I thank very you much.

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

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

{if(myLayers[i].pageItems.Length==0)}

myLayers [i] .remove ();

continue;

}

}

It works for me:

Main();

function Main() {
    var i,
    myLayers = app.activeDocument.layers.everyItem().getElements();

    for (var i = myLayers.length-1; i >=0; i--) {
        if(myLayers[i].pageItems.length == 0) {
            if (myLayers[i].name != "Grid") myLayers[i].remove();
        }
    }
}

Do not 'yet' here.

Tags: InDesign

Similar Questions

  • Is there a way to select and delete all unused layers?

    I found this issue somewhere on this forum (2008), I think that he remained unanswered.

    Maybe it's possible in CS5?

    I work with CS4 now (pc).

    Here is a workaround:

    In the contextual menu layers of Panel turn on "paste remembers layers".

    On the artboard, unlock all show all and then select all

    In the layers panel, select 'flatten the work. "

    delete all illustrations

    Dough

    Only layers with a work must return.

  • Is there a risk to delete all empty folders

    I'm a "degunking" from my computer.  I have removed several unwanted files and delete empty folders.  I would like to make a mass delition of empty folders and I wonder if there is a danger in this procedure.  The program I have to delete these folders tells me that it is y 989 on my system.

    I think you're about you for nothing.  These empty folders can be temporary custodians for a variety of applications that may not be able to recreate them when necessary.

  • How can I find all empty folders and delete them.

    My music has a bunch of files that are empty, but it will always to watch alone.  I want to search by size or someway that will make it easier to find and remove

    Hello!

    If you do not want to delete all empty folders only! go to the computer and in the top right click on search. Click type and select folder, now again click search and click on size, select 0 and click on search.

    This should list all the empty folders

    Concerning

  • move all the layers into a single layer

    Hello

    I am new to the script and I need to make a script that the passage of all the layers into one layer (in Illustrator I press CTRL + A and then CTRL + G in layers and works) but I need in the script

    Please could someone help me?

    Thank you!

    I found the solution

    main() {} function

    If (app.documents.length == 0) {return ;}

    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    var doc = app.activeDocument;

    var mast = doc.layers.add ();

    Mast.Name = "original";

    var group = mast.groupItems.add ();

    var pageIt = mast.pageItems.add ();

    While (doc.layers.length > 1)

    {

    While (doc.layers [doc.layers.length - 1].pageItems.length)

    doc. Layers [doc.layers.Length - 1] .pageItems [doc.layers [doc.layers.length - 1].pageItems.length - 1] .move (grup, ElementPlacement.PLACEATBEGINNING);

    doc. Layers [doc.layers.Length - 1] .remove ();

    }

    }

  • Delete all snapshots causing server to consume all of the available disk space.

    Hello

    I deleted all the snapshots on one of our servers and as usual, the server is passed to 95% and then sits there until it ends.   This time he ate a 150 GB Bill and is about to release one of my SAN LUNS?  Is this normal!

    In any case what can I do to save the servers, if anything?

    HELP ME PLEASE!

    Thank you

    David

    With multiple snapshots, ESX will first create a new disc in which it will merge snapshots. So depending on the size of the LUN size VMDK, sizes of snapshot, there a sense... Not funny, I know

    Tip: install a script or some tasks or alerts that monitor the use of snapshots. We have a script in place that brings all the older snapshots then 7 days. We do not allow older snapshots then 7 days, if they're going for 7 days, the 'owner' must have a very good reason why he wants to run.

    Gabrié

    http://www.GabesVirtualWorld.com

  • Button to remove all empty lines

    I am trying to create an interactive form that has a button that adds lines for the user to enter questions and another to add follow-ups to the authorities. There are 3 different sets of these. However, we do not want to add a button to remove all lines, in order to allow the accidental deletion of data already entered.  I would like to create a button that deletes all empty lines, including all subforms.  Either that, or to save the document, would be deleted all empty lines - depending on what would be easier. Help, please!  It seems that this will be a complicated task and I'm not well versed in LiveCycle to figure this on my own.

    Thank you!

    In the object > range of liaison. I've included a screenshot on the forum.

    Niall

  • All messages deleted, except one

    Woke up this morning to find that all SMS my phone had mysteriously been deleted, except one - and in this message, the entire thread has disappeared except for the most recent text (likely received after the removal of mass). Of course I don't have a recent backup, not even with iCloud, but the strange thing is that not even 3rd 3rd party apps such as phone rescue could find no trace of my texts.

    The only thing that I get out of the ordinary last night has been to plug my phone into my computer to charge. I deliberately didn't synchronize it with iTunes or Photos, because they make my computer run very slowly and I was watching a video at the same time.

    I had a conversation by chatting with someone from Apple support and they have been unable to find a solution to the problem - they advised me to configure iCloud to make sure things have increased support, but even then, they said there is no way for messages save on iCloud.

    This happened to anyone before?

    Hi Muggleborn,

    Thanks for posting in the communities of Support from Apple! I understand that you had a few messages disappear randomly on your iPhone. I can certainly understand your concern, because I would not lose anything in my posts or the other. I am pleased to provide you with advice here.

    The first thing I want to make sure that you have checked is the option to keep the text messages. You can check this setting by going to settings > Messages > keep Messages and make sure that it is set to never. The other 2 options 30 days and 1 year will delete messages after this time elapsed.

    If you haven't already done so, you will also need to restart your iPhone.

    Restart your iPhone, iPad or iPod touch

    How do I restart

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.

    Just be sure that you do not restart power mentioned in the article

    I also recommend that you backup your iPhone regularly to iTunes or to iCloud. A backup also save messages so if ever you lose information on your iPhone in the future, you can easily restore your backup. I've included some resources below that go on what is included in backups and how to get these backups going.

    On safeguards for iOS devices

    The backup of your iPhone, iPad and iPod touch

    Take care!

  • How can I delete all the email our except one

    How to delet all the email our except one

    Try the tools | Accounts show the accounts and then you can delete what you want.  If this does not help, then check out the suggestions of Fazil.

    Steve

  • [basiljs] remove all pages except one

    In a script, I create pages, export to PDF, remove pages and then create a new etc.

    Right now I use this:

    [code]

    for (var j = b.pageCount (); j > 1; j-) {}

    b.removePage (j);

    }

    [/ code]

    But it's really slow. I think that indesign made many calculation after deleting a page (deadline: link textfields) so it would be more efficient to remove all pages at once.

    Now my question is how do?

    I tested and if I delete about 5500 empty pages with the script it takes about 8 minutes.

    If I select all in indesign, and then delete it takes about 10 seconds.

    Another way to speed up a litle is to erase all the content. It will take a long time but probably a bit faster.

    Thing is that I have

    b.Clear (b.doc ());

    but this removes the master page as well and I need to keep the master page.

    In short, how to remove all pages (except one since indesign needs a single page) at the same time?

    Hello

    I will remove a lot of pages in indesign with

    • Use documentPreferences.pagesPerDocument (faster)
    • use while loop or for
    • Close doc without saving changes, and then open again. (in some cases)

    Here's the test code, run with old Macbook Air + CS5 + OSX10.7

    var pp = function (args) {
      $.writeln(args);
    }
    
    var remove_all_pages_use_pref = function (doc) {
      pp("start deleting (use preferences)");
      $.hiresTimer;
      doc.documentPreferences.pagesPerDocument = 1;
      pp("end deleting");
      pp($.hiresTimer);
    }
    
    var remove_all_pages_use_loop = function (doc) {
      var i = doc.pages.length;
      pp("start deleting (while --)");
      $.hiresTimer;
    
      while (i--) {
        if (i==1) {break;}
        doc.pages[i].remove();
      }
      pp("end deleting");
      pp($.hiresTimer);
    }
    
    function main() {
      var doc = app.documents.add();
      $.hiresTimer;
      doc.documentPreferences.pagesPerDocument = 5500;
      pp('# create 5500 pages');
      pp($.hiresTimer);
      var indd = new File("~/Desktop/5500.indd");
      doc.save(indd);
    
      pp("------------");
      remove_all_pages_use_pref(doc);
      doc.close(SaveOptions.NO);
    
      pp("------------");
      pp("# try another way");
      var doc2 = app.open(indd);
      remove_all_pages_use_loop(doc2);
      doc2.close(SaveOptions.NO);
    }
    main();
    

    result

    # create 5500 pages
    30395026
    ------------
    start deleting (use preferences)
    end deleting
    28215999
    ------------
    # try another way
    start deleting (while --)
    end deleting
    268641063
    

    Thank you

    mg

  • I want to delete cookies, except one, when I go out. Is this possible?

    I have a web site that if their cookie is deleted, I must answer several questions of security to get to where I want to be. When I'm out FireFox I want to delete all cookies EXCEPT this one. Is this feasible?

    Thank you.

    You can do this with CookieCuller extension - https://addons.mozilla.org/firefox/addon/cookieculler/

  • How can I delete all emails read without highlighting each one and delete it

    Original title: how to remove the old E-mail

    How can I delete all emails read without highlighting each one and remove it.  You want to remove them all at once.  I use Windows 7 and Windows Live Mail 2011

    To remove all the: select one and Ctrl + A will highlight all. -Delete.

    To delete a section: highlight the first one you want to remove. Scroll to last and click while holding down the SHIFT key. -Delete.

    To delete several messages that alternate: hold down the CTRL key while you click each message in order to highlight. -Delete.

    To empty the remove items, click on it and there will be an X to the right.

    SHIFT + DELETE bypasses the deleted items folder.

  • Delete all groups and layers that are turned off, even if they are locked

    Hello

    I need help with a script that will do the following:

    Delete all groups (including the layers inside) and layers so they are not visible - with the following requirements

    a. even if the group or layer is locked

    (b) even if the layers within the group are locked

    c. same layers within the group are visible, although the parent group is off

    Then... the required logic would be

    Is it group or layer turns off? Yes, then delete all independently of any other thing, OTHERWISE move on to the next layer/group

    Basically, I have a lot of groups and layers here and I want to analyze the layers to leave just the layers that are visible in the final document. Visible merge or flatten the will does not work as I want to keep visible and visible layers. Layers remove hidden does not work. And file/scripts/deleting empty layers does not work because the layers are not empty. They are simply not necessary.

    In collaboration with CS6.

    Thank you

    The other is round, but this should unlock all layers, after that delete hidden layers should work.

    // unlock all layers;
    // based on code to link layer masks by paul riggott;
    // 2014, use it at your own risk;
    #target "photoshop-70.032"
    app.bringToFront();
    if(app.documents.length != 0) {
      unlockLayers();
      };
    ////// unlock layers //////
    function unlockLayers(){
      var ref = new ActionReference();
      ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
      var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
      var Names=[];
      try{
      activeDocument.backgroundLayer;
      var i = 0; }catch(e){ var i = 1; };
      for(i;i		   
  • Regex to replace all occurrences of an empty string, except the last

    Hello, everyone!

    I need get to a regular expression to replace all occurrences of an empty string except the last. Right now I'm doing this with this code:
    public static void main(String[] args)
    {
        String str = "abc";
        String regex = "";
        System.out.println(str.replaceAll(regex, "-").replaceFirst("-$", "")); // -a-b-c
    }
    As you can see, to do this, I have to make two calls: one for replaceAll and another for replaceFirst to get rid of the last character. So I would like to get rid of the call to replaceFirst and have the variable of regex as being a regular expression that would be to insert the character along the chain of all but the last. I'm really not very good with regexs, so I ask your help here. The thing I work, but I think it would be more elegant with just a regex to do.

    Thank you in advance.

    Marcos

    Try this:

    String data = "abc";
    System.out.println(data.replaceAll(".", "-$0"));
    
  • I just lost an important note on my I-phone - since it has been deleted by mistake on one device, the cloud - I deleted all devices - how can I get it back?

    I just lost an important note on my I-phone - since it has been deleted by mistake on one device, the cloud - I deleted all devices - how can I get it back?

    Have you connected to iCloud.com and looked into the record DELETED RECENTLY?

Maybe you are looking for

  • Blue screen of death, the Satellite M100

    Hello I have Satellite M100, we had problems with the blue screen of death sometimes and then it seemed fairly constant and the only way to ensure that the system is not plant was to start it in safe mode. The noise had also stopped working. Decided

  • The PXI-1056 remote

    Hello We wondered if we could use a PXI-PCI8360 in the PXI-1056 chassis system controller housing 3U/6U?

  • Error! Camera not available!

    My phone frequently returns a message "error!" Camera is not available! "at the opening of any application that uses a camera. In this case, especially when applications that analyze bar codes them are used ('AT & T-Scanner of Code","OK Scan"), but n

  • Photosmart 5520: Not internet connection post update download

    5520 new. Connected to internet and downloaded straightup update. Now I get "server connection error... check the connection etc. This is done via the touchpad printer so the browser interface. Then... no ePrint or possible applications. Direct wirel

  • WebNavigationRequest ignore does not

    Ive tried to use the two methods Request.action = WebNavigationRequestAction.Ignore and Request.ignore) and both do not work for me. I am trying to capture my dummy url so I can parse the url to determine what to do in response to button clicks so as