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

Insert/Rename Artboard by linked image

Explorer ,
Nov 27, 2020 Nov 27, 2020

Copy link to clipboard

Copied

Hello,

 

Is there a script for when you put a linked image will insert a text with the filename of the linked and rename artboard at the same time. I don't know how to script 😞

 

elinochinjr_1-1606544995228.png

 

 

 

Thank you. This will save my workflow!

TOPICS
Feature request , Scripting

Views

517

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

Guide , Nov 27, 2020 Nov 27, 2020

 

var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
  doc.artboards.setActiveArtboardIndex(i);
  doc.selectObjectsOnActiveArtboard();
  for (var j = 0; j < selection.length; j++) {
    if (selection[j].typename == "PlacedItem") {
      var name1 = decodeURI(selection[j].file.name).replace(/\.[^\.]+$/, "");
      doc.artboards[i].name = name1;
      var d = doc.artboards[i].artboardRect;
      var rect1 = doc.pathItems.rectangle(d[1] - 10, d[0] + 10, (d[2] - d[0]) - 20
...

Votes

Translate

Translate
Guide , Dec 01, 2020 Dec 01, 2020

OK.  So you want the document name first.  Try this:

var doc = app.activeDocument;
var name1 = app.activeDocument.name;
for (var i = 0; i < doc.artboards.length; i++) {
  doc.artboards.setActiveArtboardIndex(i);
  doc.selectObjectsOnActiveArtboard();
  for (var j = 0; j < selection.length; j++) {
    if (selection[j].typename == "PlacedItem") {
      var name2 = decodeURI(selection[j].file.name).replace(/\.[^\.]+$/, "");
      doc.artboards[i].name = name2;
      var d = doc.artboards[i].artboard
...

Votes

Translate

Translate
Adobe
Guide ,
Nov 27, 2020 Nov 27, 2020

Copy link to clipboard

Copied

Insert text where? 

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
Explorer ,
Nov 27, 2020 Nov 27, 2020

Copy link to clipboard

Copied

Top left corner, please see image. thank you

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
Guide ,
Nov 27, 2020 Nov 27, 2020

Copy link to clipboard

Copied

 

var doc = app.activeDocument;
for (var i = 0; i < doc.artboards.length; i++) {
  doc.artboards.setActiveArtboardIndex(i);
  doc.selectObjectsOnActiveArtboard();
  for (var j = 0; j < selection.length; j++) {
    if (selection[j].typename == "PlacedItem") {
      var name1 = decodeURI(selection[j].file.name).replace(/\.[^\.]+$/, "");
      doc.artboards[i].name = name1;
      var d = doc.artboards[i].artboardRect;
      var rect1 = doc.pathItems.rectangle(d[1] - 10, d[0] + 10, (d[2] - d[0]) - 20, 20);
      var text1 = doc.textFrames.areaText(rect1);
      text1.contents = name1;
      break;
    }
  }
}

 

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
Explorer ,
Nov 28, 2020 Nov 28, 2020

Copy link to clipboard

Copied

Wow!! This is perfect! Thank you so much!!

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
Explorer ,
Nov 28, 2020 Nov 28, 2020

Copy link to clipboard

Copied

Can I add one more? What if I like to add the Filename itselft?

 

Sample 1:

Filename - Linked name

 

Sample 2:

Filename

Linked name

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
Guide ,
Nov 28, 2020 Nov 28, 2020

Copy link to clipboard

Copied

I am unsure what you are asking. Your options are

 

(a) the name of the placed item itself, as it appears in the layers panel

alert( app.activeDocument.placedItems[0].name );

(b) the name of the file the placed item is linked to.

alert( app.activeDocument.placedItems[0].file.name );

 

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
Explorer ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

sorry, I don't know what to do with that code 😞

This is what I want look like

elinochinjr_0-1606794295839.png

 

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
Guide ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

OK.  So you want the document name first.  Try this:

var doc = app.activeDocument;
var name1 = app.activeDocument.name;
for (var i = 0; i < doc.artboards.length; i++) {
  doc.artboards.setActiveArtboardIndex(i);
  doc.selectObjectsOnActiveArtboard();
  for (var j = 0; j < selection.length; j++) {
    if (selection[j].typename == "PlacedItem") {
      var name2 = decodeURI(selection[j].file.name).replace(/\.[^\.]+$/, "");
      doc.artboards[i].name = name2;
      var d = doc.artboards[i].artboardRect;
      var rect1 = doc.pathItems.rectangle(d[1] - 10, d[0] + 10, (d[2] - d[0]) - 20, 40);
      var text1 = doc.textFrames.areaText(rect1);
      text1.contents = name1 + " - " + name2;
      break;
    }
  }
}

 

If you want them on two separate lines, change the line before last to

text1.contents = name1 + "\r" + name2;

 

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
Explorer ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

LATEST

working!!!! Thank you thank you so much!! This is lifesaver!

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