Copy link to clipboard
Copied
I've been a huge fan of GREPs with InDesign, and wanted a similar result in Illustrator to automate some Slug info replacements. So here's my script for anyone looking/needing it.
var d = new Date();
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear().toString().substr(-2);
var dateString = month + '.' + day + '.' + year;
// Replace placeholders in all text frames
var doc = app.activeDocument;
for (var i = 0; i < doc.textFrames.length; i++) {
var textLayer = doc.textFrames[i];
if (/\{MDY\}|\{F\}|\{C\}/.test(textLayer.contents)) {
textLayer.contents = textLayer.contents.replace(/\{MDY\}/g, dateString);
var docName = doc.name.replace(/\.[^\.]+$/, ''); // remove the file extension
textLayer.contents = textLayer.contents.replace(/\{F\}/g, docName);
textLayer.contents = textLayer.contents.replace(/\{C\}/g, "YOURNAME");
}
}
This will replace the following wildcards:
{MDY} = month.day.year
{F} = filename without the extension
{C} = your name or initials
Obviously, im not as experienced as some on here, but i get a little better everyday. So hopefully it helps someone out there if you're like me and hate typing job numbers, file names, dates, etc. Modify to taste and keep on cooking. 😉
Copy link to clipboard
Copied
Hi @sublimechaos, thanks for sharing! - Mark
Copy link to clipboard
Copied
Neat, thanks.
(No upvote on original posts)