I have been working on this script for a while. I have it working up to a point. It will process a set of signs, export them as pdf, and extract a pdf’s pages into separate files. I am trying to add a way to rename them to our naming convention but so far it keeps renaming them out of order. Can anyone tell me what I’m doing wrong?
--Processing and Prepping for print happens before all this.
--Javascript to extract pages of PDF
property JavaScript : "var re = /.*\\/|\\.pdf$/ig; var filename = this.path.replace(re,\"\"); try { for (var i = 0; i < this.numPages; i++) this.extractPages( { nStart: i, cPath: filename+\"_\" + (i+1) +\".pdf\" }); } catch (e) { console.println(\"Aborted: \"+e) }" as text
set thisdoc to document 1 --this normally happens near the start, but since I skipped it...
--------------------------------------------------------------------------------
-------------------------------Process PDF ----------------------------------
--------------------------------------------------------------------------------
set exportPath to (choose folder) as string
--export document as PDFs
tell application id "com.adobe.InDesign"
activate
set myPDFexport to get the name of every PDF export preset
set myPDFchoice to ("Caldera .125 Bleed No Conversion") as string
repeat with thisdoc in (active document)
set docName to get name of thisdoc
tell thisdoc
export format PDF type to exportPath & (characters 1 thru -6 of docName) & ".pdf" using myPDFchoice without showing options
end tell
end repeat
end tell
--extract pages of PDF to home folder
tell application "Adobe Acrobat"
activate
do script JavaScript
close document 1 saving no
end tell
--close Adobe Acrobat
tell application "Adobe Acrobat" to quit
tell application "Finder"
set originalFile to exportPath & (characters 1 thru -6 of docName) & ".pdf"
if exists originalFile then delete originalFile
end tell
tell application id "com.adobe.InDesign"
activate
close thisdoc saving no
end tell
end if
end tell
tell application "Finder"
activate
display dialog "Click to Rename" buttons {"OK"} default button 1
if result = {button returned:"OK"} then
--------------------------------------------------------------------------------
-------------------------------Rename PDFs----------------------------------
--------------------------------------------------------------------------------
tell application "Finder" to set exportFiles to files of folder exportPath
set count_er to 1
repeat with i from 1 to count exportFiles
tell application "Finder" to set name of item i of exportFiles to ((characters 1 thru -6 of docName as string) & (text -2 thru -1 of ("00" & (count_er as string))) & "." & "pdf")
set count_er to count_er + 1
end repeat
end if
end tell