--choose a file to separate/will change to a choose folder?
try
set sourceFile to choose file
set userCancelled to false
on error number -128
set userCancelled to true
end try
if userCancelled then
display dialog "User cancelled."
return
end if
--get the file name then strip out the file extension
tell application "Finder"
set myName to name of sourceFile
set myName to ((characters 1 thru -5 of myName) as string)
end tell
set myName to myName & " FRONT.pdf"
--do acrobat stuff
tell application "Adobe Acrobat Pro"
activate
open sourceFile
set mediaSize to get media box of page 1 of active doc --get media box so our new doc can be made the same size
--make a new document then set its size to the source file size
set newFront to make new document
tell newFront
tell page 1
set media box to mediaSize
end tell
end tell
insert pages newFront after 0 from active doc starting with 1 number of pages 1 insert bookmarks no
bring to front newFront
end tell
--set the file path to save the new docs to
tell me to activate
set folderPath to choose folder with prompt "Choose a folder to save the separated pages to."
set defaultPath to POSIX path of folderPath
set defaultPath to defaultPath & myName
--save the new doc
tell application "Adobe Acrobat Pro"
activate
tell active doc
set myName to myName & " FRONT.pdf"
if modified is true then
save to file (defaultPath)
end if
end tell
end tell
This does everything I want it to, up to the point of saving. When it attempts to save though, I get this error in Acrobat:
"The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
Any help or pointers appreciated.
Thanks,
RJay