Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

A script to add the illustrator file name, minus extension, to a text field within the file.

Community Beginner ,
Apr 08, 2025 Apr 08, 2025

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!

TOPICS
Scripting
89
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Enthusiast ,
Apr 08, 2025 Apr 08, 2025

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");
  }
})();

SergeyOsokin_0-1744185758438.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 09, 2025 Apr 09, 2025
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines