I need help figuring out missing links & fonts before batch PDF creation on Indesign. Below is what I have so far. I’m honest with you I have been trying really really hard for weeks to make this work with little success. A very nice person on this forum was able to help me with the pdf export of the script.
The behavior I’m looking is as soon a font/link (ignore hidden layers) is missing move the InDesign file to an error folder. I have basic AS knowledge & looking for more efficient solutions. Probably what I’m asking is too much but it is going to be very beneficial for all Indesign users out there. Thank you in advance if you are willing to help me with this issue
set theFolder to choose folder with prompt "Select folder containing Indesign Documents"
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 user interaction level of script preferences to never interact
set myDocument to open (oneFile as alias)
tell myDocument
--check for missing LINKS ignore missing links on hidden layers
tell application "Adobe InDesign CS4"
tell document 1
set linkList to every link
repeat with aLink in linkList
--if status of aLink is link out of date then
--update aLink
--else
if status of aLink is link missing then
--display dialog "Please update all MISSING Links" buttons {"OK"} with icon 1 default button 1 cancel button 1
close myDocument saving no
end if
--end if
end repeat
end tell
end tell
--check for missing FONTS ignore when they are in hidden layers
tell application "Adobe InDesign CS4"
tell document 1
set fontList to every font
repeat with aFont in fontList
if fontList contains "not available" then
--display dialog "FONTS Missing" buttons {"OK"} with icon 1 default button 1 cancel button 1
close myDocument saving no
end if
end repeat
end tell
end tell
try
on error --move Indesing files w missing links & fonts to the _ERRORS folder
tell application "Finder"
if (exists folder "_ERRORS" of folder theFolder) is false then
make new folder at theFolder with properties {name:"_ERRORS"}
end if
move (every file whose name extension is {".indd"}) to theFolder with replacing
end tell
end try
-- If fine export PDF
set theFolder to file path of myDocument
set theName to name of myDocument
set text item delimiters of AppleScript to {"_"}
set theShortName to text 1 thru text item -2 of theName
--text 1 thru text item -2 is every character from the first character to the second to last text item
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
set threeDigitPageName to text -3 thru -1 of ("00" & thePageName)
(* text 1 thru 3 are the first 3 characters
text -3 thru -1 are the last 3 characters*)
set theFilePath to theFolder & "PDFs:" & theShortName & "_" & threeDigitPageName & ".pdf" as string
tell myDocument
export format PDF type to theFilePath using "PressQuality" without showing options
end tell
end repeat
end tell
end tell
set user interaction level of script preferences to interact with all
close myDocument saving no
end tell
end repeat
beep 3
with timeout of 10000 seconds
tell application "Finder"
activate
display dialog "Check the PDFs folder." buttons {" :-) OK"} with icon 1 default button 1 giving up after 15
end tell
end timeout