If you have ever received a list of fonts from a client where the font names didn’t make sense this code below will help.
Caution: Backup your fonts directory just in case.
#!/bin/sh # RenameFonts.sh # # # Created by David Kittell on 1/18/18. # # Use script like "sh RenameFonts.sh ~/Desktop/fonts/" # Prerequisite #brew install fontconfig #for f in * ; do # mv "$f" "$f.ttf" #done if [ -z ${1+x} ]; then printf "\033[01m\e[4mType your desired font directory, followed by [ENTER]:\n\e[0m\033[0m" read ftDir else ftDir=$1 fi printf "\033[36mSearch Directory:\033[0m %s \e[90m$ftDir\033[0m\n"; for file in "$ftDir"*.{ttf,otf,TTF,OTF}; do postscriptname=$(fc-scan --format "%{postscriptname}\n" $file); if [ ! -z "$postscriptname" ]; then printf "\033[36m PostScript Name:\033[0m %s \e[90m(%s)\033[0m\n" "$postscriptname" "$file"; mv "$file" "$ftDir/$postscriptname.${file##*.}" fi done