Created
December 24, 2014 19:55
-
-
Save dfrankland/92d49c90ce67b827db7e to your computer and use it in GitHub Desktop.
Font Rename Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import re | |
def changeFileName(files): | |
for file in files: | |
name = file.split("-") | |
extension = name[2].split(".")[1] | |
newFileName = ".".join([name[1],extension]) | |
os.renames(file, newFileName) | |
def getFilesWith(extension): | |
files = [] | |
for file in [file for file in os.listdir('.') if os.path.isfile(file)]: | |
if file.endswith(extension): | |
files.append(file) | |
return files | |
if __name__ == "__main__": | |
if not os.path.exists("renamed_files"): | |
os.makedirs("renamed_files") | |
for file in getFilesWith(".woff"): | |
shutil.copy(file,"renamed_files") | |
for file in getFilesWith(".svg"): | |
shutil.copy(file,"renamed_files") | |
os.chdir("renamed_files") | |
changeFileName(getFilesWith(".woff")) | |
changeFileName(getFilesWith(".svg")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment