Hello,
I came across some code from user kiwilegal from three years ago, which adds several PDFs to one book. I adapted his code to some degree, hoping to combine PDFs and replace a book rather than just adding them. I have not had much luck. Every time I run the script, the destination file keeps getting larger as files are layered into the book.
This is the script:
tell application "Finder"
set pdfList to every item of (folder "AA - Book" of folder "FAA" of folder "FXX_books")
set totalItems to number of items in pdfList
repeat with n from 1 to totalItems
end repeat
set combined_file to item 3 of (folder "FAA" of folder "FXX_books")
set appPath to path to application "Adobe Acrobat Pro"
open combined_file using appPath
end tell
tell application "Adobe Acrobat Pro"
activate
set activeDoc to the active doc
set Nm to name of item 1 of pdfList
set activeDocName to text 1 thru ((count Nm) - 4) of Nm
repeat with n from 1 to totalItems
set Nm to name of item n of pdfList
set activeDocName to text 1 thru ((count Nm) - 4) of Nm
set pageCount to count of pages of activeDoc
open (item n of pdfList) as alias
set addDoc to the active doc
set addPages to count of pages of addDoc
insert pages activeDoc after pageCount from addDoc starting with -1 number of pages addPages with insert bookmarks
close addDoc saving no
end repeat
create thumbs activeDoc
set view mode of activeDoc to pages and bookmarks
save activeDoc
close activeDoc
end tell
I would like to combine as a NEW file (document 1?) and, with a separate line of code “save as” in another location with replacing.
What’s particularly unusual since I posted this yesterday, is that the script now combines only the last page of each pdf. The only thing that changed were the pdfs in the source folder…
Any observations to clear up this fog would be most appreciated!