Rename the ttf / woff / woff2 file to the PostScript font name using Script

I am a typographer working with many fonts that have invalid or incomplete file names. I am on a Mac and use Hazel , AppleScript, and Automator workflows, trying to automate the renaming of these files *. I need a script to replace an existing file name ttf, woffor woff2in Finder with a font postscriptName. I know tools ( fc-scan/ fontconfig, TTXetc.) that can extract the PostScript name values ​​that I need, but I lack the know-how to program the script code for my purposes. I was able to configure an observable directory that the script can run when files matching certain parameters are added.

* To clarify, I'm talking about changing the file name, not the actual names stored in the font. I am also open to the script of any compatible language or script workflow, if possible, for example. this post refers to embedding AppleScript in shell script through osascript.

StackExchange messages I consulted:
How to get the Fontname from an OTF or TTF file?
How to get PostScript name for TTF font in OS X?
How to change the font name? Automating file renaming on macOS

Other:
https://github.com/dtinth/JXA-Cookbook/wiki/Using-JavaScript-for-Automation
https://github.com/fonttools/fonttools
https://github.com/devongovett / fontkit
https://www.npmjs.com/package/rename-js
https://opentype.js.org/font-inspector.html
http://www.fontgeek.net/blog/?p=343
https: //www.lantean.co/osx-renaming-fonts-for-free

: . 1) webfont, , , .
2) woff (, base64). Screenshot !

+4
1

Automator , , , , Mac bash, . , , .

, , , , , ... Apple, , "com_apple_ats_name_postscript". , "mdls" . postscript, grep name_postscript. .

... ...

mdls GenBkBasBI.ttf | grep -A1 name_postscript

... , FontBook Postscript. "A1" grep , .

com_apple_ats_name_postscript  = (
    "GentiumBookBasic-BoldItalic"

bash (tr, tail)...

tr -d \  | tail -n 1 | tr -d \"

, , , , . , "tr" .

:

mdls GenBkBasBI.ttf | grep -A1 name_postscript | tr -d \  | tail -n 1 | tr -d \" 

... ...

GentiumBookBasic-BoldItalic

, , bash. ...

Apple Automator " PDF ",

Automation Workflow

; " " "Finder".

( Get Specified...) . , .

  1. ()

,

  1. Script

bash. $F - / . - "zsh". , , "bash".

  1. ()

bash . .

  1. ()

/ .

  1. Finder: Name Single Item

"Basename", . "" 4.

+4

Source: https://habr.com/ru/post/1678129/


All Articles