-- This version takes a more straight-forward approach of repeatedly opening the document, deleting unused pages, and saving with linearizing. This approach would not have resulted in smaller file sizes in older versions of Acrobat
on open fileList
set originalFilePath to item 1 of fileList
-- Because Acrobat struggles with document names in open files, this script gets the name from the Finder, This could be done with text item delimiters parsing the file path, as shown in the alternate script
tell application "Finder"
set originalDocName to name of originalFilePath
end tell
set deskPath to path to desktop as Unicode text
tell application "Adobe Acrobat Pro"
with timeout of 600 seconds
open originalFilePath
tell document originalDocName
set pageCount to count each page
end tell
repeat with i from 1 to pageCount
if i > 1 then
open originalFilePath
end if
tell document originalDocName
if i = 1 then
delete pages first 2 last pageCount
else if i = pageCount then
delete pages first 1 last (pageCount - 1)
else
delete pages first (i + 1) last pageCount
delete pages first 1 last (i - 1)
end if
set pageName to page number of page i
end tell
set newDocName to (i as string) & ".pdf"
set newDocPath to deskPath & newDocName
save document originalDocName to file newDocPath with linearize
close document newDocName saving no
end repeat
end timeout
end tell
end open