I have some old InDesign files with missing fonts that I want to replace with new ones. I can get the names of the missing fonts get their properties, but I can’t put the font name in the find/change preferences because InDesign doesn’t recognize the font name (because it’s missing). I just get a blank and nothing changes.
Is there any way to replace missing fonts with new fonts?
tell application "Adobe InDesign CS6"
activate
tell document 1
set user interaction level of script preferences to never interact
set find text preferences to nothing
set change text preferences to nothing
set find grep preferences to nothing
set change grep preferences to nothing
set find object preferences to nothing
set find object preferences to nothing
set find glyph preferences to nothing
set change glyph preferences to nothing
set find what of find grep preferences to ".+"
set properties of find grep preferences to {applied font:"Old Font"}
set properties of change grep preferences to {applied font:"New Font"}
change grep
set user interaction level of script preferences to interact with all
end tell
end tell
set fontReplacements to {¬
({findFontName:"Benton Gothic" & tab & "Bold", findFontStyle:"Bold", changeFontName:"BentonGothic-Bold Bold", changeFontStyle:"Bold"}), ¬
({findFontName:"Benton Gothic" & tab & "Regular", findFontStyle:"Regular", changeFontName:"BentonGothic-Regular Regular", changeFontStyle:"Regular"}) ¬
}
tell application "Adobe InDesign 2023"
-- settings and option
set properties to {find text preferences:nothing, change text preferences:nothing}
set properties of find change text options to {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}
repeat with thisReplacement in fontReplacements
set fontToFind to findFontName of thisReplacement
set fontToFindStyle to findFontStyle of thisReplacement
set changeFont to changeFontName of thisReplacement
set changeFontStyle to changeFontStyle of thisReplacement
set properties of find text preferences to {applied font:fontToFind, font style:fontToFindStyle}
set properties of change text preferences to {applied font:changeFont, font style:changeFontStyle}
change text active document
end repeat
end tell