I currently use the script below to export Ai files with 100+ layers to individual Ai files. The script exports every layer in each file named after the target layer name. The problem with this is all additional layers are exported but set to non visible. Thus if the base file is 80mb every additional file is 80mb. As you can imagine this creates unnecessary file size issues.
I ask your help to amend the script so that it only exports each layer and removes the additional hidden and unnecessary layers or doesn't include the unwanted layers.
Thank you
//////////////Start
var doc = app.activeDocument; if (documents.length > 0){ // Create the illusrtratorSaveOptions object to set the AI options var saveOpts = new IllustratorSaveOptions(); // Setting IllustratorSaveOptions properties. saveOpts.embedLinkedFiles = true; saveOpts.fontSubsetThreshold = 0.0 saveOpts.pdfCompatible = true
if (doc.saved==false) doc.save(); for (i=0; i<doc.layers.length; i++) if (doc.layers[i].locked == false) doc.layers[i].visible = false; fullDocName = doc.fullName; var param = doc.name.split('.'); realDocName = param[0]; for (i=0; i<doc.layers.length; i++){ if (i-1<0) doc.layers[i].visible = true; else { doc.layers[i-1].visible = false; doc.layers[i].visible = true; } if (doc.layers[i].locked == false) { docName = doc.layers[i].name+".ai"; var saveName = new File ( doc.path + "/" + docName ); doc.saveAs( saveName, saveOpts ); } } doc.close(SaveOptions.DONOTSAVECHANGES); doc = null; app.open (fullDocName); }
/////////End