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

Script to place the File Name within the Art

Engaged ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Years ago I had been working on a Script for Illustrator project to place the File's Name (minus the extension) within the artboard.  I passed the project off and now no longer have the same computer so that solution was lost.  Is that something that someone can help me with?

 

Thank you for your time and consideration,

TOPICS
Scripting

Views

599

Translate

Translate

Report

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

correct answers 2 Correct answers

Community Expert , Oct 22, 2020 Oct 22, 2020

Hi,

Could you try this one. This is a really. basic just to get an idea that you are looking for the same. Following script assume there is one file on your desktop with name "Test".

var doc = app.activeDocument;
var file = File('~/Desktop/Test.png')
var fileName = file.name.split('.')[0];
var textFrame = doc.textFrames.add();
textFrame.contents = fileName;
app.executeMenuCommand('Fit Artboard to artwork bounds');

 

It may possible your original script have more handling of size of the text, fon

...

Votes

Translate

Translate
Community Expert , Oct 22, 2020 Oct 22, 2020

Oh,

a bit to late.

😉

 

addArtboardName();

function addArtboardName() {
var aDoc = app.activeDocument;
var aDocName = aDoc.name;
if (aDoc.artboards.length == 1) {
    var aDocName = aDoc.name.replace(/\..{2,5}$/, "");
    var Bds = aDoc.artboards[0].artboardRect;
    var aTF = aDoc.textFrames.pointText([Bds[2],Bds[3]]);
    aTF.contents = aDocName;
    aTF.translate(-aTF.width);
    }
}

 

Votes

Translate

Translate
Adobe
Engaged ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Capture.JPG

 

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Hi,

not exactly what you want - but a good base:

Script to rename artboard to filename 

 

Please describe a bit more in detail - how many artboards, which position for the textframe and so on …

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Hi,

Could you try this one. This is a really. basic just to get an idea that you are looking for the same. Following script assume there is one file on your desktop with name "Test".

var doc = app.activeDocument;
var file = File('~/Desktop/Test.png')
var fileName = file.name.split('.')[0];
var textFrame = doc.textFrames.add();
textFrame.contents = fileName;
app.executeMenuCommand('Fit Artboard to artwork bounds');

 

It may possible your original script have more handling of size of the text, fonts and anything else. 

Best regards

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Oh,

a bit to late.

😉

 

addArtboardName();

function addArtboardName() {
var aDoc = app.activeDocument;
var aDocName = aDoc.name;
if (aDoc.artboards.length == 1) {
    var aDocName = aDoc.name.replace(/\..{2,5}$/, "");
    var Bds = aDoc.artboards[0].artboardRect;
    var aTF = aDoc.textFrames.pointText([Bds[2],Bds[3]]);
    aTF.contents = aDocName;
    aTF.translate(-aTF.width);
    }
}

 

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

Not at all. Just 20 minutes.. ðŸ˜‰ 🙂

Best regards

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

😉

Es ist eher wie im Sandkasten zu spielen als in einem Duell.

It's more like playing in a sandbox than a duel.

Votes

Translate

Translate

Report

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 Expert ,
Oct 22, 2020 Oct 22, 2020

Copy link to clipboard

Copied

LATEST

A bit late too in writing an English version.

But translation feature saves me in understanding.. 🙂

Best regards

Votes

Translate

Translate

Report

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