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

Is it possible to remove all the empty artboards using script?

Community Beginner ,
Jan 29, 2017 Jan 29, 2017

Copy link to clipboard

Copied

The Question is I have nearly about 20 artboards where by chance the number of artboards used may differ based on file.

So I need to remove all the empty artboards.

TOPICS
Scripting

Views

3.5K

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

Valorous Hero , Jan 29, 2017 Jan 29, 2017

Hello!  The answer is yes, it's possible! The below snippet may be what you need.

#target illustrator

function test(){

     var doc = app.activeDocument, thisBoard, selectedObjects;

     doc.selection = null;

     for (var i = doc.artboards.length - 1; i >= 0; i--) {

          thisBoard = doc.artboards;

          if(doc.artboards.length > 1){

               doc.artboards.setActiveArtboardIndex(i);

               selectedObjects = doc.selectObjectsOnActiveArtboard();

               if(doc.selection.length

...

Votes

Translate

Translate
Community Expert , Jun 07, 2021 Jun 07, 2021

Hi,

Due to some issues of moving code to new forums, code get corrupted. Here is the corrcet version of the above code

#target illustrator

function test() {
    var doc = app.activeDocument, thisBoard, selectedObjects;
    doc.selection = null;
    for (var i = doc.artboards.length - 1; i >= 0; i--) {
        thisBoard = doc.artboards[i];
        if (doc.artboards.length > 1) {
            doc.artboards.setActiveArtboardIndex(i);
            selectedObjects = doc.selectObjectsOnActiveArtboard()
...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jan 29, 2017 Jan 29, 2017

Copy link to clipboard

Copied

Hello!  The answer is yes, it's possible! The below snippet may be what you need.

#target illustrator

function test(){

     var doc = app.activeDocument, thisBoard, selectedObjects;

     doc.selection = null;

     for (var i = doc.artboards.length - 1; i >= 0; i--) {

          thisBoard = doc.artboards;

          if(doc.artboards.length > 1){

               doc.artboards.setActiveArtboardIndex(i);

               selectedObjects = doc.selectObjectsOnActiveArtboard();

               if(doc.selection.length < 1 || doc.selection == null){

                    thisBoard.remove();

               }

          }

     }

};

test();

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
Community Beginner ,
Jan 29, 2017 Jan 29, 2017

Copy link to clipboard

Copied

Thanks it works. You helped me and my team.

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
Community Beginner ,
Apr 26, 2020 Apr 26, 2020

Copy link to clipboard

Copied

Hi there,

 

I have been able to run the script inside adobe illustrator but I keep getting this error ->

 

Error 1242: Illegal argument - argument 1
- Required value is missing
Linke:21
-> thisBoard.remove();

 

I appreciate this script was originally posted 3 years ago and illustrator has changed in that time, I wonder if anyone could help me with a new solution?

 

Just looking for an action or script to remove/delete artboards with no artwork on them (Empty Artboards) 

 

Kind Regards

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

Copy link to clipboard

Copied

Hi,

You need to have Adobe Extended Toolkit. You can download this from the creative cloud application. Apart from this you can use Extended Script debugger for Visual Code. Here is the link with more explanation

 

https://community.adobe.com/t5/indesign/extendscript-toolkit-cc-in-mojave/td-p/10443284?page=1

 

After installing it, open this application and paste above mentioned code in the new file. Try to run this script from the menu Debug --> Run. There is a short icon as well below the menu in green color. These file wille be save with the extension .jsx

 

Attached is the screenshot for the shortcut button to run the script.

 

Screenshot 2020-04-26 at 6.18.22 PM.png

 

Thanks

Charu

 

Best regards

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
Community Beginner ,
Apr 26, 2020 Apr 26, 2020

Copy link to clipboard

Copied

Thank you! I really appreciate the info!

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

Copy link to clipboard

Copied

Your welcome.

Best regards

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
Community Beginner ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Another year later… was this ever resolved? I am getting this same error and I have no idea how to fix it (yes, I have ExtendScript Toolkit).

 

Any help is appreciated!

Thanks

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
Community Expert ,
Jun 07, 2021 Jun 07, 2021

Copy link to clipboard

Copied

Hi,

Due to some issues of moving code to new forums, code get corrupted. Here is the corrcet version of the above code

#target illustrator

function test() {
    var doc = app.activeDocument, thisBoard, selectedObjects;
    doc.selection = null;
    for (var i = doc.artboards.length - 1; i >= 0; i--) {
        thisBoard = doc.artboards[i];
        if (doc.artboards.length > 1) {
            doc.artboards.setActiveArtboardIndex(i);
            selectedObjects = doc.selectObjectsOnActiveArtboard();
            if (doc.selection.length < 1 || doc.selection == null) {
                thisBoard.remove();
            }
        }
    }
};

test();

 

Best regards

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
Community Beginner ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

THANK YOU!!!!
THANK YOU!!!!

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
New Here ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Thanks! This is something I can't doing with Pure Actions, but Script+Actions made my day easy!

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
Community Expert ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

LATEST

Thank you I just discovered this thread. Amazing worflow enhancement! Immediately added it to my scripts folder in Illustrator.

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