import os personalityTable = {b"\x0f": "Wild", b"\x01": "Ojousama", b"\x1c": "Old-Fashioned Girl", b"\x11": "Crabby", b"\x19": "Lazy", b"\x17": "Otaku Girl", b"\x00": "Sexy", b"\x07": "Boyish", b"\x04": "Mysterious", b"\x16": "Trendy", b"\x14": "Nervous", b"\x18": "Yandere", b"\x12": "Unlucky Girl", b"\x0e": "Bad Girl", b"\x06": "Yamato Nadeshiko", b"\x0c": "Big Sisterly", b"\x03": "Kouhai", b"\x1b": "Stubborn", b"\x10": "Wannabe", b"\x13": "Bookish Girl", b"\x15": "Traditional Schoolgirl", b"\x0b": "Motherly", b"\x1a": "Quiet", b"\x08": "Pure", b"\x1d": "Docile", b"\x05": "Weirdo", b"\x02": "Snobby", b"\n": "Evil Eye", b"\t": "Blunt", b"\r": "Gyaru"} def main(): print("Working..\n") skippedCount = 0 errors = 0 for file in os.listdir(): if file.endswith(".png"): with open(file, "rb") as card: data = card.read() try: index = data.index(b"personality") + 11 # Get the index of personality except Exception as e: print("ERROR! Couldn't process {}, error msg: {}".format(file, e)) errors += 1 continue card.seek(index) # Seek to the index personalityByte = card.read(1) # Read the personality byte card.close() personalityReadable = personalityTable.get(personalityByte, None) if personalityReadable: renaming = True num = 1 while(renaming): filename = "{} {}.png".format(personalityReadable, num) if file == filename: skippedCount += 1 renaming = False if not os.path.exists(filename): os.rename(file, filename) renaming = False print("{} -> {}".format(file, filename)) else: num += 1 else: print("ERROR! {} has an unknown personality! Skipping..".format(file)) errors += 1 print("\n") if skippedCount: print("Ignored {} properly named card(s)".format(skippedCount)) if errors: print("{} error(s) happened! Scroll up for messages".format(errors)) if __name__ == '__main__': print("WARNING! Make sure this script is run in the female chara folder!") print("WARNING! This script targets all .png files in the folder!") print("Target folder: ", os.getcwd()) print("This script renames all cards to: {personality} {num}.png") print("Ex: Pure 1.png, Pure 2.png, Weirdo 1.png") input("\nHit ENTER to begin") main() print("Finished!") input("Hit ENTER to close")