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