I am a noobie,
I have been working with a script that modifies our documents for the end user.
In doing so the script creates blank pages that I would like to delete.
I am creating a “Clean-up” section that will run at the end. I want to include a portion that deletes these extra blank pages.
Since the script is very long”and does a million other things”I wanted to include only the important section.
repeat with ii from 1 to count of page items
set deleteExtras to count of page items
if deleteExtras is less than 1 then
delete page
end if
end repeat
tell application "Adobe InDesign CS4"
set pages_to_delete to {}
repeat with i from 1 to count of pages of document 1
set page_items to every page item of page i of document 1
if page_items is {} then
copy i to end of pages_to_delete
end if
end repeat
set reverse_pages_to_delete to reverse of pages_to_delete
repeat with this_page in reverse_pages_to_delete
delete page this_page of document 1
end repeat
end tell
This script will work as long as the “count of pages” matches the page numbers i.e. you’ve got a 10 page document and page position 8 is numbered/named as page 8 and is not the start of another section where it has been called 16 or something (hope that makes sense?). Also you may notice that once I’ve got a list of pages to delete that I reverse the list this is because if pages 7 thru 10 are blank and you delete page 7 then page 8 then becomes page 7 and you start to run into all sorts of problems so by reversing the list and deleting backwards no pages shuffle.
repeat with ii from 1 to count of every page
tell page ii
count page items
if count is less than 1
tell document 1 set label of page ii to “Delete_Me”
end if
end repeat
tell document 1 to delete every page whose label is “Delete_Me”