Custom Text Variable for file name
Hi all,
Currently now working on two systems at work each which have different job-numbering requrements.
We currently have an Indesign Startup script that gets the job number of the active document and places it as a text variable within a custom slug.
Example of current file name "000000-0_XX_PublicationName_250x150.indd" The job number is anything before the first underscore.
Here is the current code we are using...
function getJobNumber() {
try {
if (app.documents.length>0) {
var xdoc = app.activeDocument;
if (xdoc.isValid) {
var xdocname = app.activeDocument.name;
var xjobnumber = xdocname.split("_")[0];
if (xjobnumber === xdocname) {
xjobnumber = "no job number";
} else {
var xnumbercheck = Number(xjobnumber.split("-")[0]);
if (isNaN(xnumbercheck)) { xjobnumber = "no job number"};
}
}
} else {
var xjobnumber = "no job number";
}
} catch(err) {
var xjobnumber = "no job number";
}
return xjobnumber;
}
Tthe new system however requires us to have this naming convention "UK-000000-0_XX_PublicationName_250x150.indd" but the current script will not work with the "UK-" at the beginning.
It is important that this script works both ways and was wondering if there is a simple solution to this?
