Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created January 29, 2022 16:04
Show Gist options
  • Save Steffo99/4fecc2aab84132a074bf12dcab59ff16 to your computer and use it in GitHub Desktop.
Save Steffo99/4fecc2aab84132a074bf12dcab59ff16 to your computer and use it in GitHub Desktop.
Reorder and rename fonts in directory
#!/bin/fish
for file in *
set font_name (fc-query "$file" | egrep 'fullname:' | sed -E 's/fullname: \"(.+)\"\(s\)/\1/g')
set file_name (echo "$font_name" | string trim | sed -E 's/[^A-Za-z0-9]/-/g' | string lower)
set file_ext (echo (basename "$file" | string split -r -m1 ".")[2] | string lower)
set full_name (echo "$file_name.$file_ext")
mv $file $full_name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment