Delete hidden layers script

I wish, I wish for a javascript that would check my open document for hidden layers and delete them, thats all.
Thank you,
Richard

Hello try67 and thank you very much for the script.
It works well but not at 100%.
As an example:
If I have a InDesign file with 20 hidden layers. The script will delete 10, then when double-clicked again 5 more will be gone, do it again and 2 more will be deleted, so the run command needs to be repeated until all hidden layers are gone.
I cannot find any particular pattern as to the way layers are deleted and what prompt the script to stop, but I am sure there is one.
If you find out why please let me know, in the mean time this sure beats: selecting layers, right click, select delete layers, click yes, wait...
Thanks again,
Richard

Similar Messages

  • Help: Need  script help to delete hidden layers. Action errors using panel command.

    I am trying to make an action (that is using some scripts) that will delete hidden layers. When I try and action that in photoshop, the actions stops for an error if the file didn't have any hidden layers. I think I need to script it so it will delete the hidden layers, and keep going if there aen't any.
    I couldnt find anything in th ejavascript ref guide for doing this. ( I'm sure I was looking right at it, I am a noob).
    Thanks for any help you can give.

    Here is a script to will delete hidden layers but not throw an error is there are no hidden layers.
    try{
         var desc = new ActionDescriptor();
         var ref = new ActionReference();
         ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), stringIDToTypeID( "hidden" ) );
         desc.putReference( charIDToTypeID( "null" ), ref );
         executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
    }catch(e){}
    Note you could also do this with just actions steps. Have the action add a layer then hide it before the delete hidden layers menu item step. That way there would always be at least one hidden layer and no error.

  • Delete Hidden Items Script

    Hi all,
    I'm not so great with scripts, so can anyone help me out with a simple script to delete all non visible items?
    Thanks in advance for any help.

    Thanks. I've downloaded Scriptographer and will give it a go. Monika's answer was helpful however I managed to knock up this script which does pretty much exactly what I want. I only want the hidden objects to be deleted on a "Cut" layer.
    if ( app.documents.length > 0 )
        aDoc = app.activeDocument;
        var aLayer = aDoc.activeLayer;
        //alert("Active Layer: " + aLayer);
        // Delete Hidden Objects
        sourceLayer = aDoc.layers.getByName("Cut");
        var aPageItems = sourceLayer.pageItems;
        if (aPageItems.length > 0)
            for(i = 0; i < aPageItems.length; i++)
                // alert( "Element: " + sourceLayer.pageItems[i]);
                if (aPageItems[i].typename == "GroupItem")
                    // alert( "GROUPITEM");
                    var aPathItems = aPageItems[i].pathItems;
                    for(i2 = 0; i2 < aPathItems.length; i2++)
                        // alert( "Element: " + aPathItems[i2].hidden);
                        if (aPathItems[i2].hidden == true)
                            // alert( "Deleting: " + aPathItems[i2]);
                            aPathItems[i2].remove();
                    i2=i2-1;
            i=i-1;
    Thanks everyone for their help.

  • Determine if hidden layers exist

    I am building a script to cleanse photoshop documents, and one of the options I am including is to remove all hidden layers. There is no direct command to do so (or none that I have seen), so I used a chunk of code from ScriptListener to perform the 'Delete hidden layers' command.
    I only want to enable this option if there are layers that are hidden, so I'm wondering if there is a simple way to determine if any layers are hidden in the document (aside from looping through all of the layers). Or, if there's a way to determine if the 'Delete hidden layers' command is enabled or not, since that is only enabled when there are hidden layers.

    I would just bung the code between a try catch block (but I'm lazy )
    If you did want to check this should be fast...
    alert(hasHiddenLayers());
    function hasHiddenLayers(){
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
    try{
        activeDocument.backgroundLayer;
    var i = 0; }catch(e){ var i = 1; };
       for(i;i<count;i++){
           if(i == 0) continue;
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            if(layerName.match(/^<\/Layer group/) ) continue;
            if(!desc.getBoolean(charIDToTypeID( "Vsbl" ))) return true;
    return false;

  • Deleting extraneous layers via script?

    Hi there,
    I'm looking for a method of deleting unused layers (in this instance, all layers that don't contain "w2g") with script,
    is there a way of doing this? Or am I going to have to find a different way to specify the surplus layers?
    I'm really a novice at writing any kind of JS, so anything is really appreciated! Just remember to explain it like I'm five!
    Thanks

    here you go
    //  script.name = removeUnmarkedLayers.jsx
    //  script.description = removes all layers that don't have a text of your choice; i.e. add ** to all Layers you wish to keep, delete all others.
    //  script.required = an open document;
    //  script.parent = carlos canto // 08/13/2013
    //  script.elegant = false;
    // Ref. http://forums.adobe.com/thread/1274555?tstart=0
    var idoc = app.activeDocument;
    var layerCount = idoc.layers.length;
    var removelayers = [];
    var keepLayersWithThisText = prompt ('Keep Layers with this text, delete all others', 'w2g', 'Delete Unmarked Layers');
    if (keepLayersWithThisText != null) { // quit if pressed Cancel
        for (i=0; i<layerCount; i++) {
            var ilayer = idoc.layers[i];
            var idx = ilayer.name.search(keepLayersWithThisText);
            if (idx == -1)
                removelayers.push(ilayer);
        for (j=0; j<removelayers.length; j++) {
            removelayers[j].remove();
        alert (removelayers.length + ' layer(s) removed, undo is your friend');
    else alert('cancelled by user');

  • Why are my hidden layers showing up in a PDF when i convert it from an Ai file?

    When I convert an illustrator file to a PDF the hidden layers are showing up when openned by a mac or iphone. This does not happen when i send it to people with a pc and is only happening to one person. What could be causing this and how can I fix it?
    Thank you.

    That's probably because the Mac people are opening or viewing the PDFs within the Mac's "Mail" program or with the "Preview" program and not with Acrobat.
    Since the Windows people aren't using these programs and most likely just Acrobat or Adobe Reader, the layers are kept hidden.
    I'm afraid the only way to truly keep those layers hidden is to delete them before saving your file as a PDF. (Of course, do a "Save As" and keep your original .ai file intact.

  • How to set the number of hidden layers for neural network?

     I am using "Multiclass Neural Network" to build a model. I can configure number of hidden nodes, iterations etc., but I couldn't find anything to configure number of hidden layers. How to configure the number of hidden layers in Azure ML?

    Here is the article describing it - https://msdn.microsoft.com/library/azure/e8b401fb-230a-4b21-bd11-d1fda0d57c1f?f=255&MSPPError=-2147217396
    Basically, you will have to use a custom definition script in Net# (http://azure.microsoft.com/en-us/documentation/articles/machine-learning-azure-ml-netsharp-reference-guide/)
    to create hidden layers and nodes per hidden layer

  • Applescript: missing required parameter "including hidden layers"

    I've used this script (below) for packaging files in InDesign CS3, but when I upgraded to CS4 I always get this message: "Missing required parameter 'including hidden layers' for event 'package'." Does anyone know how to include this and where it goes?
    Thanks.
    on run
    display dialog "Whoa Dude, I'm a Droplet so drop an InDesign file on me"
    end run
    on open draggedItems
    tell application "Finder"
    make new folder at alias "Macintosh HD:Users:Melanie:Documents:ScriptFiles:Packaged:" with properties {name:"_Folder"}
    end tell
    set folderPath to "Macintosh HD:Users:Melanie:Documents:ScriptFiles:Packaged:_Folder:"
    repeat with currentFile in draggedItems
    tell application "Adobe InDesign CS4"
    set openedfile to open (currentFile as alias)
    set theDoc to (document 1)
    tell document 1
    package to folderPath copying fonts yes copying linked graphics yes copying profiles no updating graphics yes ignore preflight errors yes creating report yes
    set fileName to (name of theDoc)
    set filepath to folderPath & fileName & ".pdf"
    export openedfile format "Adobe PDF" to filepath using "[Smallest File Size]"
    save openedfile
    close openedfile
    end tell
    tell application "Finder"
    set NewName to fileName & "_Folder"
    set name of folder folderPath to NewName
    end tell
    end tell
    end repeat
    end open
    ---------

    I don't use InDesign/CS4, but it seems clear that the 'package' command now has additional parameters that you're not including in the command.
    Since it's telling you that 'including hidden layers' is the parameter that's missing, just append it to the packagecommand, with either a 'yes' or a 'no' depending on what you want:
    package to folderPath copying fonts yes copying linked graphics yes copying profiles no updating graphics yes ignore preflight errors yes creating report yes including hidden layers no

  • Delete multiple Layers by selecting multiple object?

    Hi Designers,
    I'm going to connect my AI file to After effect.
    So I had to create lots of layers in order to edit them seperatly in After effects.
    But it seems like my amount of layers are too large because AE always crashes (not responding -> Force quit)
    So I wanna break some stuff down in multiple AI files, but I don't wanna go and select every layer and delete it.
    That would take too much time.
    Is there a way to select the multiple objects in Illustrator and delete that but also its layer its in?
    Thank you!

    MisterStylow wrote:
    Delete multiple Layers by selecting multiple object?
    So I wanna break some stuff down in multiple AI files, but I don't wanna go and select every layer and delete it. That would take too much time.
    [Q:] Is there a way to select the multiple objects in Illustrator and delete that but also its layer its in?
    You could do that via a script, here is a quick example:
    // Purpose: Select multiple objects and delete them along with their layer
    // Note: However, it does not differentiate sublayer structures
    // Just select your desired items, then run this script snippet,
    // to remove the selected items along with the layer they are on.
    var doc = app.activeDocument;
    for (var i = doc.layers.length - 1; i >= 0; i--) {
        var layerID = doc.layers[i];
        if (layerID.hasSelectedArtwork == true) {
            layerID.remove();
    Hope it proves useful to your efforts and workflow. Keep us posted.

  • How do I export to PDF in InDesign without the hidden layers

    Hi there
    This is probably a simple solution but I am trying to export a document to PDF in InDesign without the hidden layers.
    i.e - I have created a document that includes images etc from an existing PDF.
    When I open the new PDF and use the 'find' tool, Pro is highlighting words on the hidden (original pdf).
    I have tried exporting only the visible layers but is there a setting in InDesign that I can use to export only the visible content to pdf?
    Thanks in advance.

    Jenjimay wrote:
    I have tried exporting only the visible layers but is there a setting in InDesign that I can use to export only the visible content to pdf?
    Even if you mask off part of a PDF, or place a white rectange on top of it, the text will still be selectable. Other than with raster images, InDesign is not smart enough to clip off parts of a PDF (or rather, it's smart enough to leave them as they are). PDFs can contain incredibly complex objects, and any clipping routine would probably make as many mistakes as it solves problems.
    Introduce a small Transparency to this image or one on top of it, then export with Acrobat 4 (PDF 1.3) settings. Since that old version does not support native transparency, ID is forced to redraw the image, and then it will clip off excess data.

  • QuickLook / Preview and PDFs with hidden layers

    Hidden layers in PDF files show up in preview, quicklook and in the generated thumbnails. Is there any known fix for this to get the content to render with only the visible layers?

    It would help to look at a sample. Can you post one?
    Also, check the "Show Large Images" Page Display preference.

  • Does Safari support a interactive PDF with hidden layers? I'm on version  5.0.3 and the interactive PDF displays just fine, but our web development team tells me all the layers display when they view the same PDF on Safari.

    Does Safari support interactive PDFs with layers? Through the use of hidden layers and buttons we built in interactivity that allows the viewers to click on buttons to display different content. When I view the PDF in Safari 5.0.3 on my Mac OS 10.5.8 the PDF displays fine and the interactivity works. However our web design firm tell me the PDF displays all the hidden layers when they view it in Safari. Who's right?

    Try updating your Safari to the latest version, 5.0.5.
    Also check whether the rest of your system is up to date by going to Software Update in the Apple menu.

  • How do I Reveal/Hide Hidden Layers for viewing with Acrobat Reader (iPad)?

    Hi,
    I've created a document in Quark Xpress with multiple layers which I then exported to a PDF. Using Acrobat Pro I created hotspots which revealed/hid these layers on rollover. It works perfectly on the desktop version of Acrobat Reader but not on Acrobat Reader for iPad (where the hidden layers are automatically switched on and touching the hotspots does not hide them). Does anybody know a good work around to this?

    There are many features which are possible in the desktop version of Adobe Reader which won't work in Reader for tablets. I think this is one of them. Probably no workaround possible until the feature is updated.

  • Uploaded page does not correctly display hidden layers

    Hi,
    I am a bit baffled by this as I haven't seen this in all my
    years using Dreamweaver.
    I have created a few links, that when rolled over they
    display a hidden layer that contains a styled table of contents (No
    links in the tables).
    This works perfectly as expected on my testing server, but
    when it is uploaded to the client webserver, the hidden layers
    display below each link, throwing the page out completely, and also
    the CSS style does not apply.
    Is there something on the clients webserver that needs to be
    changed or tweeked to recognise hidden layers, CSS etc?
    Cheers

    Are the layers actually hidden in the code? I mean when you
    look at the
    code view of the page (either in the CSS or the inline styles
    for the
    layers, depending on what DW version you are using), do you
    see -
    visibility:hidden
    or -
    visibility:visible
    Which?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Macnimation" <[email protected]> wrote in
    message
    news:e3q43i$1hg$[email protected]..
    > Hi,
    >
    > I am a bit baffled by this as I haven't seen this in all
    my years using
    > Dreamweaver.
    >
    > I have created a few links, that when rolled over they
    display a hidden
    > layer
    > that contains a styled table of contents (No links in
    the tables).
    >
    > This works perfectly as expected on my testing server,
    but when it is
    > uploaded
    > to the client webserver, the hidden layers display below
    each link,
    > throwing
    > the page out completely, and also the CSS style does not
    apply.
    >
    > Is there something on the clients webserver that needs
    to be changed or
    > tweeked to recognise hidden layers, CSS etc?
    >
    > Cheers
    >

  • Hidden layers get PDFed anyway

    Hello all,
    I've been meaning to ask this for a while now:
    Whenever I hide InDesign layers; then Export to a PDF; and choose Visible Layers (in the General options); and finish up and OK the producing of the PDF; the dialog immediately warns me that stuff from hidden layers will be in the PDF anyway! Sure enought there is!
    Why?
    Also, is there a way in Acrobat 8 or 9 Pro to remove an entire layer (OCG, in Acrobat-speak) along with its objects all at once?
    I can't find it if it does this.
    Mike Witherell in Maryland

    The world's spun a few times since then Peter. I'm trying to think back.
    I had a raft of buttons on a separate layer forming an index (call these buttons B). I could turn this layer on using a
    button (call this button A) on the page in view, and a button on the index layer (call this button C) could then hide it
    again.
    The PDF was exported with all layers.
    The visibility or otherwise was determined by the button options - visible in PDF or hidden.
    So button A which turned on the raft of buttons forming the index was set to visible, but all the buttons on the index
    raft (buttons B and C) were set to hidden. Mouse down of button A had the behaviour to show each of buttons B and button
    C and hide button A - you have to list each event separately in the actions attributed to each button.
    Mouse down of button C then hid buttons B and C and showed button A.
    The crux I think is what you can define as a "field" for the purposes of the Button Option menu > Behaviors > Behavior >
    Show/Hide Fields. I was defining buttons as fields. I can't remember/never knew whether you could define a layer as a
    field. I think probably not, and you would have to make the contents of a layer a single button or selection of buttons
    and then define them initially as visible or not visible in the PDF.
    k

Maybe you are looking for

  • Problem loading yahoo mail in safari os x lion

    When i browse safari with different site was fine but when i load up yahoo mail to check my email, it turn out to be sluggish or even to the point that it will not load. the other website that i'm already in, will get affected that i could even force

  • Group by sort order and display accordingly

    I have two groups - primary sort order and a secondary sort order in my report, formula for both follows: If {?Sort Order}='1' then {PRODUCT_CUSTOMER_MNT_V.CUSTOMER_NAME} else if {?Sort Order}='2' then {PRODUCT_CUSTOMER_MNT_V.PRODUCT_ID} else if {?So

  • Co-ordinates of active page in active doc

    I want to get the co-ordinates on the page, for the center of the active document screen. Also which page it is. Thanks in advance for any help on my first acrobat tryout (though I have done quite a bit of InDesign Scripting)

  • Unlimted European Subscription listed as active bu...

    Hi, I have a 3 month unlimited European subscription which has been listed as active since 11th July, however, I am being charged for landline calls to the UK and Netherlands which should be covered in this subscription type.  Why is this happening a

  • Ipod touch doesn't appear under devices.  message - file not found.

    My ipod touch doesn't appear under devices when I plug it into the computer.  My mac tried to sync with the ipod touch and then gave me the message "ipod touch could not be synced.  File not found."  This just suddenly started.  What file? and what h