Skip to main content
Participant
November 24, 2023
Question

Java script for finding active artboard dimensions for illustration batch files

  • November 24, 2023
  • 2 replies
  • 438 views

Hello folks,

I am new to this forum, currently working on a project where i recieved a bunch of illustration batch files (1000 plus files in eps format) , with no coding knowledge

 

Requirement: i need a script or code that run through this bunch of illustrator batch files (eps files) at a time and fetches the active artboard width and height dimensions for all batch files and print this data in an excel.

can any one guide me on this,

Thanks in advance,

This topic has been closed for replies.

2 replies

Inspiring
November 27, 2023
Select the folder containing the eps
Create a csv on the same level
 
↓script
-----
 
//Header
sNo = "S.No"
sName = "Name"
sWpt = "Active artboard width in points"
sHpt = "Active artboard height in points"
//
sFileType = "eps"
 
main();
 
function main(){
folderRef = Folder.selectDialog("Select Folder");
if( folderRef != false){
fileList = folderRef.getFiles("*." + sFileType)
if( fileList != false){
fileList.sort(compare)
sText = sNo + "," + sName + "," + sWpt + "," + sHpt
ifl = fileList.length
for (var i=0;i<ifl;i++){
sText += "\r" 
fileObj = new File(fileList[i].fsName);
app.userInteractionLevel=UserInteractionLevel.DONTDISPLAYALERTS;
open(fileObj);
app.userInteractionLevel=UserInteractionLevel.DISPLAYALERTS;
oDoc = app.activeDocument;
sText += i+1
sText += "," + decodeURI(oDoc.name.replace(("." + sFileType),""))
sText += "," + (oDoc.artboards[0].artboardRect[2]-oDoc.artboards[0].artboardRect[0]) + " pt"
sText += "," + -(oDoc.artboards[0].artboardRect[3]-oDoc.artboards[0].artboardRect[1]) + " pt"
oDoc.close(SaveOptions.DONOTSAVECHANGES);
oDoc = null
};
var oFile = new File(folderRef.path + "/" + "Output.csv") ;
oFile.open ("w","","");
oFile.encoding = "UTF-8"
oFile.writeln(sText);
};
};
}
function compare(a,b){
regex = new RegExp(/[0-9]+/);
    index = 0
    a_num = parseInt(a.name.match(regex))
    b_num = parseInt(b.name.match(regex))
 
 
    if (a_num > b_num) {
        index = 1
    }else if (a_num < b_num) {
        index = -1
    }
    return index
}
Kurt Gold
Community Expert
Community Expert
November 24, 2023

There are already a couple of scripts for Adobe Bridge which can do it hand over fist.

 

You may do a search for "extract metadata script adobe bridge" or something similar.