Skip to content

Instantly share code, notes, and snippets.

@vjandrei
Created December 7, 2022 11:29
Show Gist options
  • Save vjandrei/e9198f59fd47ef747fe6dc54758e9157 to your computer and use it in GitHub Desktop.
Save vjandrei/e9198f59fd47ef747fe6dc54758e9157 to your computer and use it in GitHub Desktop.
Order FontAwesome icons svgs to folder category
# To get the categories https://github.com/FortAwesome/Font-Awesome/blob/master/metadata/categories.yml
# Convert yml to json
# Download icons from https://github.com/FortAwesome/Font-Awesome/tree/master/svgs or from Font-Awesome website
# Run .py code
import json
import os
import shutil
# Opening JSON file
f = open('./categories.json')
# Getting svgs files and folder
svgsFolder = 'svgs'
svgsFilesDirectory = os.path.join(os.path.dirname(__file__), svgsFolder)
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for category_list in data['categories']:
for key, value in category_list.items():
iconDircectory= os.path.join(svgsFilesDirectory, key)
os.mkdir(iconDircectory)
print("Directory '% s' created" % iconDircectory)
for icon in value['icons']:
file = str(icon) + '.svg'
file_name = os.path.join(svgsFilesDirectory, file)
destination = str(iconDircectory) + '/'
print(destination)
shutil.copy(file_name, destination)
print("Files Moved")
# Closing file
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment