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

Script to delete pages with images and its graphic frames

Engaged ,
Feb 15, 2023 Feb 15, 2023

Hi

I have an indesign document that contain 1000 pages from data merge process ...each page consists of background image and and image in circle graphic frame .

Now Please I want a 2 scripts

1- One that delets all pages that contain empty graphic frame ( has No images in its graphic frame )

2- Second that delets all pages that contain graphic frame ( has images in its graphic frame )

 

Thanks For your help in advance

 

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

Community Expert , Feb 15, 2023 Feb 15, 2023

Use my second script. It removes pages with graphics in the oval. Remove the /* and */ to do the viceversa. This assumes only one oval per page. 

 

var ps = app.activeDocument.pages;
var i = ps.length;
while(i--) {
    if (/*!*/ps[i].ovals[0].graphics.length) {
        ps[i].remove();
    }
}

 

 

Translate
Community Expert ,
Feb 15, 2023 Feb 15, 2023

Do you want to remove pages that have no graphics at all? Or just if the ovals have no graphics? This removes all pages with graphics. Remove the /* and */ to remove all pages without graphics. 

 

var ps = app.activeDocument.pages;
var i = pages.length;
while(i--) {
    if (/*!*/ps[i].allGraphics.length) {
        ps[i].remove();
    }
}

 

 If you only want to remove based on oval layout, then same concept using the following, assuming only one oval per page:

 

var ps = app.activeDocument.pages;
var i = pages.length;
while(i--) {
    if (/*!*/ps[i].ovals[0].graphics.length) {
        ps[i].remove();
    }
}

 

 

 

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
Engaged ,
Feb 15, 2023 Feb 15, 2023

Thanks For Your reply

But I want to delete all pages that contain images in its oval graphic frame and leave other page that not cantain images and vise versa

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 ,
Feb 15, 2023 Feb 15, 2023

Use my second script. It removes pages with graphics in the oval. Remove the /* and */ to do the viceversa. This assumes only one oval per page. 

 

var ps = app.activeDocument.pages;
var i = ps.length;
while(i--) {
    if (/*!*/ps[i].ovals[0].graphics.length) {
        ps[i].remove();
    }
}

 

 

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
Engaged ,
Feb 15, 2023 Feb 15, 2023

Thanks

But this error apears when I used your second script

Shown below 

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 ,
Feb 15, 2023 Feb 15, 2023

Ooops, just edited above. pages.length should have been ps.length

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
Engaged ,
Feb 15, 2023 Feb 15, 2023
LATEST

Very Great thanks For You

2 Scripts Work like charm

Thaaaanks Alot

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
Engaged ,
Feb 15, 2023 Feb 15, 2023

Any Help

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