Highlighted

Script to place the File Name within the Art

Participant ,
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,

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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. 

TOPICS
Scripting

Views

114

Likes

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

Script to place the File Name within the Art

Participant ,
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,

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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. 

TOPICS
Scripting

Views

115

Likes

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

Copy link to clipboard

Copied

Capture.JPG

Likes

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
Reply
Loading...
Oct 22, 2020 1
Most Valuable Participant ,
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 …

Likes

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
Reply
Loading...
Oct 22, 2020 2
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Oct 22, 2020 2
Most Valuable Participant ,
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);
    }
}

 

Likes

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
Reply
Loading...
Oct 22, 2020 1
Adobe Community Professional ,
Oct 22, 2020

Copy link to clipboard

Copied

Not at all. Just 20 minutes.. 😉 🙂

Best regards

Likes

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
Reply
Loading...
Oct 22, 2020 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Oct 22, 2020 1
Adobe Community Professional ,
Oct 22, 2020

Copy link to clipboard

Copied

A bit late too in writing an English version.

But translation feature saves me in understanding.. 🙂

Best regards

Likes

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
Reply
Loading...
Oct 22, 2020 1
Resources