Highlighted

Script to rename artboards to filename + specific suffix

New Here ,
Apr 22, 2020

Copy link to clipboard

Copied

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

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

 

TOPICS
Scripting

Views

493

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 rename artboards to filename + specific suffix

New Here ,
Apr 22, 2020

Copy link to clipboard

Copied

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

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

 

TOPICS
Scripting

Views

494

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
Apr 22, 2020 0
Engaged ,
Apr 22, 2020

Copy link to clipboard

Copied

 

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];
}

 

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...
Apr 22, 2020 2
Most Valuable Participant ,
Apr 23, 2020

Copy link to clipboard

Copied

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";

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...
Apr 23, 2020 1
New Here ,
Apr 23, 2020

Copy link to clipboard

Copied

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

 

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