• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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!

TOPICS
How to , Scripting

Views

829

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

In my sig - ID-Tasker.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

Thank you, I will read your website about your tool.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

The files are in a flat structure in a network RAID. I want to:

 

1. Open a file

2. Dismiss the dialog complaining of missing Links

3. List the fonts used in the document

4. Print the list to a text file together with the name of the document

5. Close the file
and so on.

My aim is to end up with a big text file listing all the fonts used in all the files. There are about 700 files involved.

I have InDesign on a Mac. I have a Windows machine too, and I could get InDesign for the PC if I had to.

Thank you for any help you can give!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

quote

The files are in a flat structure in a network RAID. I want to:

 

1. Open a file

2. Dismiss the dialog complaining of missing Links

3. List the fonts used in the document

4. Print the list to a text file together with the name of the document

5. Close the file
and so on.

My aim is to end up with a big text file listing all the fonts used in all the files. There are about 700 files involved.

I have InDesign on a Mac. I have a Windows machine too, and I could get InDesign for the PC if I had to.

Thank you for any help you can give!

 

By @Richard27439456ewpv

 

RobertTkaczyk_2-1712769103129.png

 

This will process ANY number of files in ANY location.

 

First Task - run in "single" mode - loads info about documents you want to process - from the selected folder and all sub-folders. Of course, you can then check the list and sort & filter out files you don't want to process.

RobertTkaczyk_1-1712770614786.png

 

Second Task - run in BatchMode - open each document, load Styles info, export, close without saving.

 

The current "drawback" - it exports more than you need - but you can always delete unwanted columns... Text and Styles have 400+ properties - you can extract even all of them if you wish. 

 

RobertTkaczyk_3-1712769163109.png

 

So you will be interested in those two columns + FileName:

RobertTkaczyk_0-1712769474755.png

 

But you need to give me few minutes to upload new version.

 

 

Already uploaded. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

@Richard27439456ewpv 

 

Or you can make it faster:

RobertTkaczyk_0-1712787415629.png

by removing Clear rules and Reporting...

 

...so you'll get one long list - sorted by NAME & DOC - or any other way:

RobertTkaczyk_1-1712787695392.png

 

And then, using 3rd Task, you can export everything together in one go.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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:

 

Screen Shot 1.png

 

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();
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

Thanks everyone!

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

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

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

quote

[...]

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


By @Nick Passmore

 

Mine has been tested on 1000s of files, yes, it takes a few hours, so best left overnight.

 

In case anything goes wrong - there is an error log - so it won't just stop - it will go to the next file - but there needs to be "Close Document with(out) saving" rule at the end.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Here's a better version that has some error trapping for missing fonts and that opens the InDesign docs without a window to speed things up.

It does 50 10/11mb files in about 100 seconds on my 2020 Intel MacBook.

 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--set BT to current date
property RootPath : missing value
property TextOut : ("File Name" & tab & "Family" & tab & "Font Style" & tab & "Type" & tab & "PS Name" & tab & "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
--display dialog ((current date) - BT)
on MakeFontList(FilePath)
	tell application id "com.adobe.InDesign"
		set user interaction level of script preferences to never interact
		open file FilePath without showing window
		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
				try
					set FT to font type
				on error
					set FT to "Unknown"
				end try
				set PS to PostScript name
				try
					set LO to location
				on error
					set LO to "Missing"
				end try
				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 saving no
		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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Using ChatGPT to help, I embroidered your AppleScript to the following:

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

property RootPath : missing value
property NotCheckedFiles : {} -- List to store filenames of files not checked

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

-- Save list of files not checked to "notchecked.txt"
set notCheckedFile to (open for access file (RootPath & "notchecked.txt") with write permission)
repeat with eachFile in NotCheckedFiles
write eachFile & linefeed to notCheckedFile starting at eof
end repeat
close access notCheckedFile

display dialog "Font extraction completed for all InDesign files." buttons {"OK"} default button "OK"

on MakeFontList(FilePath)
set TextOut to ("Family\tFont Style\tType\tPS Name\tLocation" & return)
set DocName to ""
tell application id "com.adobe.InDesign"
set user interaction level of script preferences to never interact
try
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
try
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
on error errMsg
-- Handle font-related errors by logging
log errMsg
end try
end repeat
on error errMsg
-- Handle document-related errors by logging and adding filename to not checked list
log errMsg
set end of NotCheckedFiles to FilePath -- Add filename to the list of not checked files
end try
close document 1 saving no -- Close the document after processing or in case of error
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

This analyses the folder of INDD files, prints the fonts used into text files, and makes a text file of any file it failed to analyse. It prints a 'finished' message when it ends.

So that's really useful. 

Thanks to everyone for your help!!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

LATEST

Very glad to hear you got this to work — 700 books is quite a pile!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines