Missing Fonts & Links

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

Hi there,

this going back a while now but this is the routine I used to use in CS4:


tell application "Adobe InDesign CS4"
	set the_links to every link of active document
	repeat with this_link in the_links
		set link_props to properties of this_link
		set link_name to name of link_props
		if (get status of this_link) is link out of date then
			set update_button to button returned of (display dialog link_name & " needs updating. Would you like to update the file now?" buttons {"No", "Yes"} default button "Yes" with icon 1)
			if update_button = "Yes" then
				update this_link
			else
				error number -128
			end if
		else if (get status of this_link) is link missing then
			display dialog "missing link:" & return & link_name & return & "Please relink before continuing!" buttons {"OK"} with icon 0
			error number -128
		end if
	end repeat
end tell

missing fonts:

	tell application "Adobe InDesign CS4"
		if (get status of this_fonts_props as string) is "not available" then
			display dialog (name of this_fonts_props) & " is missing!" & return & "Please correct this before continuing." with icon 0
			error number -128
		end if
	end tell

Hope it helps,
Nik

Thank you blend. that helps. Since the script is batching I dont want to stop & display the error (which is currently happening on the script. It stops completely). Example an error is found then close document, don’t save & continue with the next document. How can I do that?

Hi,

there are still a few areas that could be streamlined in the script but hopefully this will give you the idea:

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"

tell application "Adobe InDesign CS4"
	activate
	set user interaction level of script preferences to never interact
	repeat with oneFile in theFiles
		
		set myDocument to open (oneFile as alias)
		set activeDoc to true
		
		set the_links to every link of myDocument
		repeat with this_link in the_links
			set link_props to properties of this_link
			set link_name to name of link_props
			if (get status of this_link) is link out of date then
				update this_link
			else if (get status of this_link) is link missing then
				close myDocument saving no
				set activeDoc to false
			end if
		end repeat
		
		if activeDoc then
			set font_props to properties of every font of active document
			repeat with this_fonts_props in font_props
				if (get status of this_fonts_props as string) is "not available" then
					close myDocument saving no
					set activeDoc to false
				end if
			end repeat
		end if
		
		if activeDoc is false then
			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 oneFile to folder ((theFolder as string) & "_ERRORS") with replacing
			end tell
		end if
		
		if activeDoc then
			set filenameNoExt to do shell script "FILENAME=$(basename " & quoted form of POSIX path of (oneFile as string) & ");NOEXT=${FILENAME%.*}; echo $NOEXT" --trim extension from filename
			
			tell application "Finder"
				set PDFfolder to ((theFolder as string) & "PDFs")
				if (exists folder PDFfolder) is false then
					make folder at theFolder with properties {name:"PDFs"}
				end if
			end tell
			
			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 threeDigitPageName to text -3 thru -1 of ("00" & thePageName)
				set theFilePath to PDFfolder & ":" & filenameNoExt & "_" & threeDigitPageName & ".pdf"
				
				export myDocument format PDF type to theFilePath using "[Press Quality]" without showing options
			end repeat
			close myDocument saving no
		end if
		
	end repeat
	set user interaction level of script preferences to interact with all
end tell

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

Thanks,
Nik

Thanks Blend3. I revisiting this script again. I’m getting this error when there is a link missing.

error “Adobe InDesign CS4 got an error: Can’t get properties of link id 198277 of imported page id 215218 of rectangle id 198281 of page id 185 of master spread id 179 of document "AB_718.indd".” number -1728 from properties of link id 198277 of imported page id 215218 of rectangle id 198281 of page id 185 of master spread id 179 of document “AB_718.indd”