Copy link to clipboard
Copied
Hi, Im trying to find a way to add the illustrator file name to a text field within a table in the same illustrator file. When the file name gets updated, the text field also automatically gets updated. Similar to how it works in Indesign Text Variables > Insert Variable > File Name. Unfortuantely illustrator does not work in the same way.
I found a script to add the file name, but it doesnt update. If anyone has any scripts that would work, I would appreciate your feedback. Thanks!
Copy link to clipboard
Copied
So you close the file and rename it. You open the file again, and you want the text frame to update automatically? Scripts only change the document when you run the script.
If you have a text object with a key name in the file, you will need to run the script each time to insert the filename into it. Example:
(function (){
var doc = app.activeDocument;
var docName = doc.name.replace(/\.[^\.]+$/, '')
var targetName = "filename";
try {
var target = doc.textFrames.getByName(targetName);
target.contents = docName;
} catch (error) {
alert("Text frame '" + targetName + "' not found");
}
})();
Copy link to clipboard
Copied
Thanks Sergey. Yes, I would ideally like it to work as it does in Indesign, as that is automatic. I guess there is no automated option for illustrator.