Highlighted

Auto Rename Artboards Based On Placed Image Filename

Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

Is there a way wether it be through a script or third party plugin to auto rename a series of artboards within a file based on the placed image within each artboard?

 

Scenario: If I am doing t-shirt mockups and have 3 artboards each with a different shirt images and want to export jpgs of each artboard and have them named based off of the filenames of each shirt image. Would be very convenient to have the artboards renamed automatically based on the placed shirt image filename vs manually changing the name of each artboard. 


Thanks!

 

 

You beat me to it, Silly-V.  This is what I cam up with:

 

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") {
      doc.artboards[i].name = selection[j].name;
    }
  }
}

 

 

TOPICS
Feature request, Import and export, Scripting, Third party plugins

Views

105

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

Auto Rename Artboards Based On Placed Image Filename

Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

Is there a way wether it be through a script or third party plugin to auto rename a series of artboards within a file based on the placed image within each artboard?

 

Scenario: If I am doing t-shirt mockups and have 3 artboards each with a different shirt images and want to export jpgs of each artboard and have them named based off of the filenames of each shirt image. Would be very convenient to have the artboards renamed automatically based on the placed shirt image filename vs manually changing the name of each artboard. 


Thanks!

 

 

You beat me to it, Silly-V.  This is what I cam up with:

 

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") {
      doc.artboards[i].name = selection[j].name;
    }
  }
}

 

 

TOPICS
Feature request, Import and export, Scripting, Third party plugins

Views

106

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 08, 2020 2
Adobe Community Professional ,
Oct 08, 2020

Copy link to clipboard

Copied

This should do the trick:

 

#target illustrator
function test(){
	var doc = app.activeDocument;
	var boards = doc.artboards;
	var thisBoard, artItemOnBoard, placedItemName;
	for (var i = 0; i < boards.length; i++) {
		thisBoard = boards[i];
		doc.artboards.setActiveArtboardIndex(i);
		doc.selection = null;
		doc.selectObjectsOnActiveArtboard();
		for (var j = 0; j < doc.selection.length; j++) {
			artItemOnBoard = doc.selection[j];
			if (artItemOnBoard.typename == "PlacedItem") {
				placedItemName = decodeURI(artItemOnBoard.file.name).replace(/\.[^\.]+$/, "");
				thisBoard.name = placedItemName;
			}
		}
	}
}
test();

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 08, 2020 2
Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

Sorry, what is the best way to add this in? I have used scripts before but previously just downloaded them. Thanks for your help!

 

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 08, 2020 1
Engaged ,
Oct 08, 2020

Copy link to clipboard

Copied

You beat me to it, Silly-V.  This is what I cam up with:

 

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") {
      doc.artboards[i].name = selection[j].name;
    }
  }
}

 

 

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 08, 2020 2
Engaged ,
Oct 08, 2020

Copy link to clipboard

Copied

Copy and paste it in a jsx file. (You can create a txt file and change the extension to jsx.)

 

Then, while your document is open in Illustrator, go to File > Scripts > Other Script (Ctrl+F12). Find your script and open it.

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 08, 2020 1
Community Beginner ,
Oct 08, 2020

Copy link to clipboard

Copied

You both are awesome. Thanks!

 

I got Silly-V's script to work but couldn't get femkeblanco's to work.

Appreciate the quick fix to this!

 

Thanks!

 

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 08, 2020 0
Community Beginner ,
Oct 09, 2020

Copy link to clipboard

Copied

This may work for some but I couldn't get it to work on my end. Thanks!

 

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 09, 2020 1
Community Beginner ,
Oct 09, 2020

Copy link to clipboard

Copied

This worked great. Thanks!

 

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 09, 2020 0
WA_ART LATEST
Community Beginner ,
Oct 09, 2020

Copy link to clipboard

Copied

Correction: Both scripts work! I tried again and made a new script file from femkeblanco's script and is working now so I may have missed something when I copied the text originally.

 

The difference that I am noticing between the two is that Silly-V's script does not include the filename extension in the artboard name.  Femkeblanco's script does include the filename extension in the artboard name.

 

Both versions will be useful for me in the future and wanted to pass this along for anyone that may prefer one over the other.

Thanks again for the quick solution to this!

 

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 09, 2020 1