Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Script to Automate Deletion of Specific Layers #79345
    Alex Lee
    Member

    Hi all,

    I enlisted the help of our IT guru here at work, and he’s substantially changed the code to make it work.

    Where ‘var arr = [“xxx”,”xxx”];

    is where you specify the layers you want to delete.

    Now trying to find a definitive removed unused paragraph, character, object styles and swatches to add to this script…

    //Films_Slick Templates.jsx
    //An InDesign JavaScript
    /*
    @@@BUILDINFO@@@ “Films_Slick Templates.jsx” v1.0 November 2015
    */
    //This script will prepare any slick template format for use for Films specific use, including DVD, Blu-ray, Fatpack and 12 disc Fatpack.
    //Huge Thanks to Tom Byrne for making this code work, originally provided on indesignsecrets.com user loicaigon.

    //For more information on InDesign scripting, go to https://www.adobe.com/products/indesign/scripting/index.html
    //Or visit the InDesign Scripting User to User forum at https://www.adobeforums.com.
    //
    function removeLayers ( layersNamesArray ) {
    var d, ls, l, n, r, c = 0;
    if ( !app.documents.length || !layersNamesArray ||!(layersNamesArray instanceof Array) )
    return;

    d=app.activeDocument;
    ls = d.layers;

    for (var i = 0; i < ls.length; i++)
    {
    for (var j = 0; j < arr.length; j++)
    {
    l = ls[i];
    if (l.name == arr[j])
    {
    l.remove();
    c++;
    //Reset the loop and start again
    i = 0;
    break;
    }
    }
    }
    alert( c>0? “Removed “+c+” layers” : “Removed none layers” );
    }
    var arr = [“TV Licensor Logos and Inner Slick Template Layout Elements”,”Anime Licensor Logos (if not included, obtain logo from raw assets or previously done slick)”,”Disc Number Icon Back (Palace / No QR Code – Black)”,”Disc Number Icon Back (Palace / No QR Code – White)”,”Country of Origin Flags (Palace / No QR Code White Text)”,”Country of Origin Flags (Palace / No QR Code Black Text)”,”Specs Box Cartoon Network/Adult Swim (White)”,”Specs Box Cartoon Network/Adult Swim (Black)”,”Specs Box (Palace / No QR Code – White)”,”Specs Box (Palace / No QR Code – Black)”,”Specs Box Anime/Pop Culture (Black)”,”Specs Box Anime/Pop Culture (White)”,”Studio Ghibli Layout Elements”,”Adult Swim Layout Elements”,”Cartoon Network Layout Elements (Madman Logo Not present on front)”,”Directors Suite Layout Elements”,”Palace Layout Elements”,”SBS Template Elements”];
    removeLayers(arr);

    in reply to: Script to Automate Deletion of Specific Layers #79302
    Alex Lee
    Member

    It’s taken a little longer than expected, but my InDesign master tempate for this is now done.

    I’ve created a first script to hopefully get right, before rolling out to other formats. Needless to say, as I’m a scripting newbie, it doesn’t work :-)

    I’ve used the code sample supplied by ‘loicaigon’ earlier in this forum thread (although we’re on Macs, I felt using a platform agnostic script language would be best for future proofing), but when I run it (and check the .jsx’s syntax in The ExtendScript Toolkit) there’s an error on line 20. Here’s the complete code and I’ve separated line 20 out with paragraph breaks:

    //PopCultureTemplate.jsx
    //An InDesign JavaScript
    /*
    @@@BUILDINFO@@@ “PopCultureSlickTemplates.jsx” v1.0 November 2015
    */
    //This script will prepare any slick template format for use for Pop Culture/Anime specific use, including DVD, Blu-ray, Fatpack and 12 disc Fatpack formats.

    //For more information on InDesign scripting, go to https://www.adobe.com/products/indesign/scripting/index.html
    //Or visit the InDesign Scripting User to User forum at https://www.adobeforums.com.
    //
    main();
    function removeLayers ( layersNamesArray ) {
    var d, ls, l, n, r, c = 0;
    if ( !app.documents.length
    || !layersNamesArray
    ||!(layersNamesArray instanceof Array) ) return;
    d=app.activeDocument;
    ls = d.layers;
    n = ls.length;

    r = new RegExp (“^(“+layersNamesArray.join(“|”)+”)$”, “” );

    while ( n– ) {
    l = ls[n];
    if ( r.test ( l.name ) && n>0 ) {
    l.remove()
    c++;
    }
    }
    alert( c>0? “Removed “+c+” layers” : “Removed none layers” );
    }
    var arr = [“TV LIcensor Logos and Inner Slick Template Layout Elements”,”Disc Number Icon Back (Palace / No QR Code – Black)”,“Disc Number Icon Back (Palace / No QR Code – White)”,“Specs Box Cartoon Network/Adult Swim (White)”,“Specs Box Cartoon Network/Adult Swim (Black)”,“Specs Box (Palace / No QR Code – White)”,“Specs Box (Palace / No QR Code – White)”,“Specs Box (Palace / No QR Code – Black)”,“Specs Box Films/TV (Black)”,“Specs Box Films/TV (White)”,“Studio Ghibli Layout Elements”,“Adult Swim Layout Elements”,“Cartoon Network Layout Elements (Madman Logo Not present on front)”,“Directors Suite Layout Elements”,“Palace Layout Elements”,“SBS Template Elements”];
    var u;
    app.doScript (“removeLayers(arr);”, u,u, UndoModes.ENTIRE_SCRIPT );

    I thought it could be because it was using different quote marks than expected, but I tried some variations and it’s no good. I don’t know what else to try in terms of syntax that Javascript will understand.

    Help me Scripti-Wan-Kenobi(s), you’re my only hope!

    – Alex

    in reply to: Script to Automate Deletion of Specific Layers #78762
    Alex Lee
    Member

    Thanks Trisha and loicaigon!

    I’ll try out both (if you haven’t guessed, I’m completely new to scripting but hoping with an example to follow, it’ll just be down to specifying the layers I want to delete between different scripts).

    I’m hoping to complete my rather complex template in the next 3 weeks, and only then will I be ready to set up the scripts once all the layers are in place. I’ll keep everyone posted!

    – Alex

Viewing 3 posts - 1 through 3 (of 3 total)