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

How to exclude artboard name when exporting JPEGs with "exportForScreens" script in Illustrator?

Contributor ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

Hello everyone!

I have a question about using a script in Illustrator to export JPEGs. When using the following code: 

doc.exportForScreens(jpegOutPath, ExportForScreensType.SE_JPEG100, jpegOptions, whatToExport, 'art_');

the exported JPEG file names contain the name of the artboard. How can I export the JPEGs without the artboard name in the file name?

Thank you!

 

screen.png

TOPICS
Scripting

Views

343

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 1 Correct answer

Community Expert , Aug 31, 2023 Aug 31, 2023

What do you want to name them then? I see the prefix "art_" but if you export multiple artboards they would successfully overwrite each other if they didn't include the artboard name. I have a method of doing what you are asking but you'll need to differentiate the filenames in some way so they don't overwrite each other. If you are only exporting one artboard at a time (I don't know what you set in your `whatToExport` var) then that is pretty easy as shown in the code below.

var doc = app.active
...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

What do you want to name them then? I see the prefix "art_" but if you export multiple artboards they would successfully overwrite each other if they didn't include the artboard name. I have a method of doing what you are asking but you'll need to differentiate the filenames in some way so they don't overwrite each other. If you are only exporting one artboard at a time (I don't know what you set in your `whatToExport` var) then that is pretty easy as shown in the code below.

var doc = app.activeDocument;

var artboard_idx = 0; // artboard you want to export (0-based index)
var artboard = doc.artboards[artboard_idx];
var prefix = "art_";

var jpegParam = new ExportForScreensOptionsJPEG();
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = artboard_idx + 1 + "";

doc.exportForScreens(
  doc.path,
  ExportForScreensType.SE_JPEG100,
  jpegParam,
  whatToExport,
  prefix
);

// When exporting artboard using the exportForScreens method, the api adds
// "Artboad" to the actual artboard name resulting in `{prefix}Artboard X.{extension}`
// To be able to correctly name the exported file, I am recreating the known
// naming convention with a new `file` object to that path and then just renaming the file.
exportedFile = new File(doc.path + "/" + prefix + artboard.name + ".jpg");
exportedFile.rename(prefix + ".jpg");

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
Contributor ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

Thank you very much for your response! I originally planned to use ‘art_’ for variable naming, but now I’m prepared to use the artboard name for variable naming. Of course, your method may be more convenient. Also, does ‘ExportForScreensType.SE_JPEG100’ have only four values: 20_50_80_100? Thanks again for your response!

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
Enthusiast ,
Sep 01, 2023 Sep 01, 2023

Copy link to clipboard

Copied

LATEST

Yes. Adobe's documentation only lists four values: SE_JPEG100, SE_JPEG80, SE_JPEG50, SE_JPEG20.

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