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

Script to rename artboards to filename + specific suffix

New Here ,
Apr 22, 2020 Apr 22, 2020

I'm looking to create a script or action that renames my artboards to the filename + a specific suffix. 

In the example below with the file name U101-G001.pdf I'd like the artboards to:

U101-G001_fty

U101-G001_th

 

is this possible?

 

Screen Shot 2020-04-22 at 2.41.07 PM.png

TOPICS
Scripting
1.5K
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

correct answers 1 Correct answer

New Here , Apr 23, 2020 Apr 23, 2020

This is pretty close. I don't need the extention.  I was able to cobble below together and it works, but lots of code. 

 

// Add filename to artboard plus custom suffix, set below "New Name 1", "New Name 2", "New Name 3"

var aDoc = app.activeDocument;

var which_artBoard_to_rename = 1; // set number of the artboard you want to change - should be 1 or higher; max = max number of artboards in your document

abIdx = which_artBoard_to_rename - 1;

aDoc.artboards[0].name = aDoc.name.substring(0,aDoc.name.last

...
Translate
Adobe
Guide ,
Apr 22, 2020 Apr 22, 2020

 

var doc1 = app.activeDocument;
doc1.artboards[0].name = doc1.name + "_fty";
doc1.artboards[1].name = doc1.name + "_th";

 

Alternatively:

 

var suffix = ["_suffix1", "_suffix2", "_suffix3"/*et cetera*/];
var doc1 = app.activeDocument;
var abs1 = doc1.artboards;
for (var i = 0; i < abs1.length; i++) {
  abs1[i].name = doc1.name + suffix[i];
}

 

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 Expert ,
Apr 23, 2020 Apr 23, 2020

Yours is good - but not exactly what the OP wants.

I think it should be more like that:

var doc1 = app.activeDocument;
var nme = doc1.name.replace(/\.pdf/i, "");
doc1.artboards[0].name = nme + "_fty";
doc1.artboards[1].name = nme + "_th";
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
New Here ,
Apr 23, 2020 Apr 23, 2020
LATEST

This is pretty close. I don't need the extention.  I was able to cobble below together and it works, but lots of code. 

 

// Add filename to artboard plus custom suffix, set below "New Name 1", "New Name 2", "New Name 3"

var aDoc = app.activeDocument;

var which_artBoard_to_rename = 1; // set number of the artboard you want to change - should be 1 or higher; max = max number of artboards in your document

abIdx = which_artBoard_to_rename - 1;

aDoc.artboards[0].name = aDoc.name.substring(0,aDoc.name.lastIndexOf("."))+"New Name 1"; // set the new name here

aDoc.artboards[1].name = aDoc.name.substring(0,aDoc.name.lastIndexOf("."))+"New Name 2"; // set the new name here

aDoc.artboards[2].name = aDoc.name.substring(0,aDoc.name.lastIndexOf("."))+"New Name 3"; // set the new name here

 

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