import os, sys
import math
from pathlib import Path
pref = "YOSS"
angcount = 16
target = Path('C:/Users/-----/Documents\Blender texture image stuff\Textures\Textures\Low-fi\Sprites\YellowCrawla')
dirs = os.listdir(target)
letterdict = dict({
1: ["0"],
5 : ["1","28","37","46","5"],
8 : ["1","2","3","4","5","6","7","8"],
9 : ["1", "9G", "28", "AF", "37", "BE", "46", "CD", "5"],
16 : ["1", "9", "2", "A", "3", "B", "4", "C", "5", "D", "6", "E", "7", "F", "8", "G"]
})
startchar = 'A'
for file in dirs:
if file.startswith(pref):
imagenumber = dirs.index(file)
letters = list(letterdict[16])
suffix = letters[int(imagenumber%16)]
if imagenumber == 16:
startchar = 'B'
elif imagenumber == 16*2:
startchar = 'C'
elif imagenumber == 16*3:
startchar = 'D'
elif imagenumber == 16*4:
startchar = 'E'
elif imagenumber == 16*5:
startchar = 'F'
elif imagenumber == 16*6:
startchar = 'G'
elif imagenumber == 16*7:
startchar = 'H'
elif imagenumber == 16*8:
startchar = 'I'
elif imagenumber == 16*9:
startchar = 'J'
elif imagenumber == 16*10:
startchar = 'K'
elif imagenumber == 16*11:
startchar = 'L'
elif imagenumber == 16*12:
startchar = 'M'
elif imagenumber == 16*13:
startchar = 'N'
elif imagenumber == 16*14:
startchar = 'O'
elif imagenumber == 16*15:
startchar = 'P'
elif imagenumber == 16*16:
startchar = 'Q'
elif imagenumber == 16*17:
startchar = 'R'
elif imagenumber == 16*18:
startchar = 'S'
elif imagenumber == 16*19:
startchar = 'T'
elif imagenumber == 16*20:
startchar = 'U'
elif imagenumber == 16*21:
startchar = 'V'
elif imagenumber == 16*22:
startchar = 'W'
elif imagenumber == 16*23:
startchar = 'X'
elif imagenumber == 16*24:
startchar = 'Y'
elif imagenumber == 16*25:
startchar = 'Z'
elif imagenumber >= 16*26:
print('too many frames')
targetpath = os.path.join(target,os.path.relpath(file))
newname = pref+startchar+str(suffix)+str('.png')
newpath = Path(str(target)+("/")+str(newname))
print(newpath)
if not os.path.exists(newpath):
os.rename(targetpath,newpath)
else:
print('file already exists, doing nothing')