I have a lot of illustrator files that are organized by a template size. The layers are setup so that the top level layer is always Template. However the sublayer I need to move to the top level could be called 42 Pg Border or 30 Pg Border or 24 Pg Border.
Is there a way for a script to search through the layers and if it finds "42 Pg Border" or "30 Pg Border" or "24 Pg Border" in the sublayer Template it would move it to the top level but if it doesn't see one of those it doesn't give an error?
I'm still new to scripting so the extent of my knowledge on this is to scan all the layers and unlock them. Then look for a specific layer name. It's the sublayer and moving it to the top level that I am not sure of.
Here is my current code:
var doc = app.activeDocument; var allLayers = doc.layers; for (var i = allLayers.length-1; i >= 0; i--){ allLayers[i].locked = false; if (allLayers[i].name == "42 Pg Border" || allLayers[i].name == "30 Pg Border" || allLayers[i].name == "24 Pg Border") { alert("I found the " + allLayers[i].name + " layer") } else { alert("Not the right layer") } }
Any help would be greatly appreciated!
I am using CS4 on a Windows 64 Bit PC with JavaScript