Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from os import listdir
- from os.path import isfile, join
- import os
- import string
- mypath = "./Emoji_Images/set_512"
- onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
- add0skintone = set()
- for f in onlyfiles:
- if "_" in f:
- #Gotta Do Some shit
- skintone = ""
- manwoman = ""
- filename = f
- f = f[:-4]
- if f[0] == "u":
- f = f[1:]
- codes = string.split(f, "_")
- for index, code in enumerate(codes):
- if code == "1F3FB":
- skintone = 1
- codes[index] = None
- if code == "1F3FC":
- skintone = 2
- codes[index] = None
- if code == "1F3FD":
- skintone = 3
- codes[index] = None
- if code == "1F3FE":
- skintone = 4
- codes[index] = None
- if code == "1F3FF":
- skintone = 5
- codes[index] = None
- if code == "2640":
- manwoman = "W"
- codes[index] = None
- if code == "2642":
- manwoman = "M"
- codes[index] = None
- if code == "200D" or code == "FE0F":
- codes[index] = None
- if skintone != "" or manwoman != "":
- noMod = codes[0]
- for index, code in enumerate(codes):
- if code is not None and index is not 0:
- noMod += "_200D_"+code
- #print noMod
- if skintone is not "":
- add0skintone.add(str(noMod))
- if skintone is "":
- if noMod in add0skintone:
- skintone = 0
- newname = "u"+noMod
- if skintone is not "":
- newname +="."+str(skintone)
- if manwoman is not "":
- newname+="."+str(manwoman)
- newname += ".png"
- print filename, newname
- os.rename(mypath+"/"+filename, mypath+"/"+newname)
- for f in onlyfiles:
- if f[0] == "u":
- noMod = f[1:]
- noMod = noMod[:-4]
- if noMod in add0skintone or noMod[:-5] in add0skintone:
- newname = "u"+noMod+".0.png"
- print mypath+"/"+f, mypath+"/"+newname
- os.rename(mypath+"/"+f, mypath+"/"+newname)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement