I would like to be able to run a script to update the artwork slug that we always run in the bottom of our artwork. I have found a script that does most of what I require. There are pre-defined boxes that are filled by the script:
#target illustrator
function main() {
if (app.documents.length == 0) {
alert("Please have an 'Illustrator' document before running this script.");
return;
}
var docRef = app.activeDocument;
with (docRef) {
if (saved == false) save();
var filePath = path;
if (inCollection(textFrames, 'titleblock-file')) {
var frameA = textFrames.getByName('titleblock-file');
frameA.contents = name;
}
if (inCollection(textFrames, 'titleblock-path')) {
var frameB = textFrames.getByName('titleblock-path');
frameB.contents = unescape(fullName);
}
if (inCollection(textFrames, 'titleblock-version')) {
var frameC = textFrames.getByName('titleblock-version');
if (filePath.created != null) {
var verNum = 0;
verNum++;
frameC.contents = verNum;
}
}
if (inCollection(textFrames, 'titleblock-revised')) {
var frameD = textFrames.getByName('titleblock-revised');
if (filePath.modified != null) {
var modDate = filePath.modified.toString().split(' ');
var modDate = modDate[1] + ' ' + modDate[2] + ' ' + modDate[3];
frameD.contents = modDate;
}
}
if (inCollection(textFrames, 'titleblock-editor')) {
var frameE = textFrames.getByName('titleblock-editor');
frameE.contents = 'DW'
}
}
}
main();
function inCollection(objArray, nameString) {
var x = false;
for (var i = 0; i < objArray.length; i++) {
if (objArray[i].name == nameString) x = true;
}
return x;
}
The bit about verNum is mine! And it doesn't work as intended. I imagine I need to somehow grab the existing number from the text frame in Illustrator and then increment it. But have no idea how to do so.
Any help greatly appreciated