Create folder + save artboard in it
Hi,
I created a script to check if the folder is created and if not it will create it.
Then I save my 2 artboards (its a master file so users will always have the two artboards) into this folder.
The folder is named after the artboard 1 (which is index 0).
I then save my file before starting to export (because I guess once I'll export the eps my file will be the eps it self)Once saved I save my first artboard in jpeg in this folder.
Once done I save my second artboard (index 1) to the same folder in jpeg + eps.
Questions are :
- Why won't it run?.. nothing happens when I run the script in illustrator.
- Will the eps file have only the arts within the artboard? if not, is there a way to delete what's out of bound and only keep what's within this said artboard?
maybe changing "saveDoc= app.activeDocument;" by the artboard(1)?
Thanks a lot guys. This forum been really helpful.
It's only my fourth script so it might be messy a bit.
var targetDoc = app.activeDocument;
var Name = targetDoc.artboards[0].name;
var folder = new Folder ("F:/DevEcusson/" + Name);
function main ()
{
if (!folder.exists) folder.create();
targetDoc.save();
SaveArtboard1();
saveArtboard2();
}
function SaveArtboard1 ()
{
app.activeDocument.artboards.setActiveArtboardIndex(0);
var jpgName = targetDoc.artboards[0].name + ".jpeg";
exportFileToJPEG (folder + jpgName, 72);
}
function SaveArtboard2 ()
{
app.activeDocument.artboards.setActiveArtboardIndex(1);
var jpgName = targetDoc.artboards[1].name + ".jpeg";
var epsName = targetDoc.artboards[1].name + ".eps";
exportFileToJPEG (folder + jpgName, 72);
exportFileAsEps (folder + epsName);
}
function exportFileToJPEG (dest, resolution)
{
var exportOptions = new ExportOptionsJPEG();
var type = ExportType.JPEG;
var fileSpec = new File(dest);
exportOptions.antiAliasing = true;
exportOptions.artBoardClipping = true;
exportOptions.horizontalScale = resolution*100/72;
exportOptions.verticalScale = resolution*100/72;
exportOptions.qualitySetting = 100;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
function exportFileAsEps (destFile)
{
var newFile = new File(destFile);
var saveDoc;
if (app.documents.lenght == 0)
saveDoc = app.documents.add();
else
saveDoc= app.activeDocument;
saveOpts.cmykPostScript = true;
saveOpts.emdedAllFonts = true;
saveDoc.saveAs(newFile, saveOpts);
}
