Skip to main content
Participating Frequently
April 10, 2024
Question

How can I automatically export lists of font used in a file?

  • April 10, 2024
  • 3 replies
  • 2032 views

I have been dumped an archive of InDesign books layouts which were done 5+ years ago. Some of the fonts are obsolete and need to be replaced. There are hundreds of files in this archive.

 

I want a script to open each file, ignore the warning that the Links are missing, check the fonts in the document, and print this to a text file named for the document being checked, close the document and go on to the next one. I started playing around with the scripting tools but I've got stuck.

 

Has anyone solved this problem already? Googling has not been successful.

 

Thanks in advance for any help you can give!

This topic has been closed for replies.

3 replies

rob day
Community Expert
Community Expert
April 10, 2024

I started playing around with the scripting tools but I've got stuck.

 

Hi @Richard27439456ewpv , This JavaScript would write a text file in the same folder as the INDD file with a list of Type1 fonts used in the document:

 

 

var d = app.activeDocument
var f = d.fonts.everyItem().getElements()

var s = d.name + " Type 1 fonts: \r"
for (var i = 0; i < f.length; i++){
    if (f[i].fontType == 1718899761) {
        s += f[i].name + "\r"
    } 
};  
writeText(d.filePath + "/" + d.name + " Type1 Font List", s) 



function writeText(p,s){
    var file = new File(p);
    file.encoding = 'UTF-8';
    file.open('w');
    file.write(s);
    file.close();
}
Participating Frequently
April 10, 2024

Thanks everyone!

I will give all this a proper go tomorrow because my brain is tired. (UK based.)

Participating Frequently
April 10, 2024

Here's another version. (Also from the UK.)

It will work through all the InDesign files in the folder the user selects.

It now saves a single tab-delimited file named Font List.txt for each run in the same folder as the ID files.

It records the document name, font family, font style name, font type, PostScript name, location.

Whether it will process 700 files at once I would not like to guess!

 

 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property RootPath : missing value
property TextOut : ("File Name	Family	Font Style	Type	PS Name	Location" & return)
set RootPath to ((choose folder with prompt "Please select a folder to process:") as text)

set Filelist to (list folder RootPath without invisibles)

repeat with f from 1 to count of items of Filelist
	set NextName to (item f of Filelist)
	if NextName ends with ".indd" then
		MakeFontList(RootPath & NextName)
	end if
end repeat

set NewFile to (open for access file (RootPath & "Font List.txt") with write permission)
write TextOut to NewFile starting at eof
close access NewFile

on MakeFontList(FilePath)
	tell application id "com.adobe.InDesign"
		set user interaction level of script preferences to never interact
		open file FilePath
		tell document 1
			set DocName to name
			set DocName to CleanDocName(DocName) of me
			log DocName
			set n to fonts
		end tell
		repeat with i from 1 to count of items of n
			tell item i of n
				set FN to font family
				set FS to font style name
				set FT to font type
				set PS to PostScript name
				set LO to location
				set LO to DocName & tab & FN & tab & FS & tab & FT & tab & PS & tab & LO
				set TextOut to TextOut & LO & return
			end tell
		end repeat
		close document 1
		set user interaction level of script preferences to interact with all
	end tell
	
end MakeFontList

on CleanDocName(n)
	set AppleScript's text item delimiters to {""}
	set n to ((characters 1 thru -6 of n) as text)
	return n
end CleanDocName

 

 

Participating Frequently
April 10, 2024

I have written something very similar in the past.

Do you just want a list of the font names or do you need to know the font type, for instance, to see Type 1 fonts that need to be replaced?

Are the InDesign documents all in one place and how many hundreds are we talking about?

 

Participating Frequently
April 10, 2024
This AppleScript may do what you want.  
You would need to paste it into Script Editor and run it from that or save it as a compiled script and run it from InDesign's script palette. 
When you paste it, make sure the quotation marks don't get smartened. 

 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property RootPath : missing value

set RootPath to ((choose folder with prompt "Please select a folder to process:") as text)

set Filelist to (list folder RootPath without invisibles)

repeat with f from 1 to count of items of Filelist
	set NextName to (item f of Filelist)
	if NextName ends with ".indd" then
		MakeFontList(RootPath & NextName)
	end if
end repeat

on MakeFontList(FilePath)
	set TextOut to ("Family	Font Style	Type	PS Name	Location" & return)
	tell application id "com.adobe.InDesign"
		set user interaction level of script preferences to never interact
		open file FilePath
		tell document 1
			set DocName to name
			set DocName to CleanDocName(DocName) of me
			log DocName
			set n to fonts
		end tell
		repeat with i from 1 to count of items of n
			tell item i of n
				set FN to font family
				set FS to font style name
				set FT to font type
				set PS to PostScript name
				set LO to location
				set LO to FN & tab & FS & tab & FT & tab & PS & tab & LO
				set TextOut to TextOut & LO & return
			end tell
		end repeat
		close document 1
		set user interaction level of script preferences to interact with all
	end tell
	set NewFile to (open for access file (RootPath & DocName & ".txt") with write permission)
	write TextOut to NewFile starting at eof
	close access NewFile
end MakeFontList

on CleanDocName(n)
	set AppleScript's text item delimiters to {""}
	set n to ((characters 1 thru -6 of n) as text)
	return n
end CleanDocName

 

Robert at ID-Tasker
Legend
April 10, 2024

If you work on a PC - yes, my tool can do that - and a lot more.

 

Participating Frequently
April 10, 2024

Hi Robert,

I've got a Windows PC and a Mac. The InDesign is on the Mac but I could get a PC licence to help with this task.


What is your tool?

Thanks....

Robert at ID-Tasker
Legend
April 10, 2024

In my sig - ID-Tasker.