Below is a script that will create single page PDFs from ID. I want to keep part of the original inDesign file name but not the page number when the PDF is done. I want the actual section-page number in 3 digit format.
Example this is the original InDesign file name:
ABC.BUS_Q_4-5.indd (Bold & italic is part the file name I want)
CC14_200.indd
CF.14_C_20-22.indd
Current final result when PDF is done:
ABC.BUS_4.pdf (missing Q on file name & page needs to be 004)
ABC.BUS_5.pdf (missing Q on File name & page needs to be 005)
CC14_200.pdf (This case is perfect because there is only one underscore on the original file name & the page number has 3 digits)
CF.14_20.pdf (missing C on File name & page number needs to be 020.pdf)
CF.14_21.pdf (missing C on File name & page number needs to be 021.pdf)
CF.14_22.pdf (missing C on File name & page number needs to be 022.pdf)
The TIDs are set up to {_} I know anything after the underscore is the actual section/page number but I don’t know how to make TID’s to go to the second _ underscore if exists on FileName. TIDs is a concept I kind understand but it is hard to implement for me. I did some tutorials but I can’t make it to work. Or is better to have a display dialog asking the user in which part of the file name you want the name delimited? suggestions please.
This what I have so far
set theFolder to choose folder
tell application "Finder" to set theFiles to files of theFolder whose name extension is "indd"
repeat with oneFile in theFiles
tell application "Adobe InDesign CS4"
activate
set myDocument to open (oneFile as alias)
tell myDocument
set theFolder to file path of myDocument
set theName to name of myDocument
set text item delimiters of AppleScript to {"_"}
set theShortName to text item 1 of theName
set text item delimiters of AppleScript to ""
tell application "Finder"
if (exists folder "PDFs" of folder theFolder) is false then
make folder at theFolder with properties {name:"PDFs"}
end if
end tell
tell application "Adobe InDesign CS4"
repeat with x from 1 to count pages of myDocument
set thePageName to name of page x of myDocument
set page range of PDF export preferences to thePageName
set theFilePath to theFolder & "PDFs:" & theShortName & "_" & thePageName & ".pdf" as string
tell myDocument
export format PDF type to theFilePath using "Press-Crop" without showing options
end tell
end repeat
end tell
end tell
close myDocument saving no
end tell
end repeat
beep 3
with timeout of 10000 seconds
tell application "Finder"
activate
display dialog "DONE :-)" buttons {"OK"} default button 1 giving up after 5
end tell
end timeout
Model: iMac intel
AppleScript: 2.3
Browser: Safari 537.11
Operating System: Mac OS X (10.6)