Advertisement
Kafke

Untitled

Apr 29th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. from os import listdir
  2. from os.path import isfile, join
  3. import os
  4. import string
  5. mypath = "./Emoji_Images/set_512"
  6. onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
  7.  
  8. add0skintone = set()
  9. for f in onlyfiles:
  10.     if "_" in f:
  11.         #Gotta Do Some shit
  12.         skintone = ""
  13.         manwoman = ""
  14.         filename = f
  15.         f = f[:-4]
  16.         if f[0] == "u":
  17.             f = f[1:]
  18.         codes = string.split(f, "_")
  19.         for index, code in enumerate(codes):
  20.             if code == "1F3FB":
  21.                 skintone = 1
  22.                 codes[index] = None
  23.             if code == "1F3FC":
  24.                 skintone = 2
  25.                 codes[index] = None
  26.             if code == "1F3FD":
  27.                 skintone = 3
  28.                 codes[index] = None
  29.             if code == "1F3FE":
  30.                 skintone = 4
  31.                 codes[index] = None
  32.             if code == "1F3FF":
  33.                 skintone = 5
  34.                 codes[index] = None
  35.             if code == "2640":
  36.                 manwoman = "W"
  37.                 codes[index] = None
  38.             if code == "2642":
  39.                 manwoman = "M"
  40.                 codes[index] = None
  41.             if code == "200D" or code == "FE0F":
  42.                 codes[index] = None
  43.         if skintone != "" or manwoman != "":
  44.             noMod = codes[0]
  45.             for index, code in enumerate(codes):
  46.                 if code is not None and index is not 0:
  47.                     noMod += "_200D_"+code
  48.             #print noMod
  49.             if skintone is not "":
  50.                 add0skintone.add(str(noMod))
  51.            
  52.             if skintone is "":
  53.                 if noMod in add0skintone:
  54.                     skintone = 0
  55.        
  56.             newname = "u"+noMod
  57.  
  58.             if skintone is not "":
  59.                 newname +="."+str(skintone)
  60.             if manwoman is not "":
  61.                 newname+="."+str(manwoman)
  62.             newname += ".png"
  63.             print filename, newname
  64.             os.rename(mypath+"/"+filename, mypath+"/"+newname)
  65.  
  66. for f in onlyfiles:
  67.     if f[0] == "u":
  68.         noMod = f[1:]
  69.    
  70.     noMod = noMod[:-4]
  71.     if noMod in add0skintone or noMod[:-5] in add0skintone:
  72.         newname = "u"+noMod+".0.png"
  73.         print mypath+"/"+f, mypath+"/"+newname
  74.         os.rename(mypath+"/"+f, mypath+"/"+newname)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement