Created
August 26, 2019 08:32
-
-
Save NBprojekt/a5591ca9465c58aa778b23e3e4b96b30 to your computer and use it in GitHub Desktop.
This script is made for simple cleaning up of downloaded icon packages
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
# This script is made for simple cleaning up of downloaded icon packages | |
# - Remove meaningless chars in front of the name | |
# - Remove not needed folders | |
# - Move folder into 'packs' folder for better structure | |
import shutil, os, glob | |
path = input("Select pack name: ") | |
files = os.listdir(path + "/svg") | |
fileExtensions = ["eps", "license", "png", "psd", "svg"] | |
print("\nMoving and renaming all files from " + path + "/svg") | |
for file in enumerate(files): | |
filename = "" | |
for s in file.split("-")[1:]: | |
filename += s | |
if os.path.exists(os.path.join(path, file.split("-")[1])): | |
count = int(len(glob.glob1(path, file.split("-")[1].split(".")[0]+"*"))) + int(len(glob.glob1(path + "/svg", file.split("-")[1]))) | |
filename = filename.split(".")[0] +"-"+ str(count) + ".svg" | |
os.rename(os.path.join(path + "/svg", file), os.path.join(path, filename)) | |
print("\nCleaning up " + path) | |
for f in fileExtensions: | |
if os.path.exists(path + "/" + f): shutil.rmtree(path + "/" + f) | |
print("\nMoving " + path + " into pack folder") | |
shutil.move(path, "packs/"+path) | |
print("\nDone.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment