#Usage: #Drop this script in to your female chara folder and run it #You can edit the filename format on line 107 #Troubleshooting: #Getting errors or other issues? Update python #Also make sure the cards aren't open in any other program import os import re 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"\x0a": "Evil Eye", b"\x09": "Blunt", b"\x0d": "Gyaru"} def formatName(name): invalidCharacters = ["\\","/",":","*","?","<",">","|"] filename = "" for char in name: if char in invalidCharacters: continue else: filename += char return filename def main(): print("Working..\n") skippedCount = 0 errors = [] for file in os.listdir(): if file.endswith(".png"): with open(file, "rb") as card: try: data = card.read() index = data.index(b"lastname") # All the interesting info is over here except Exception as e: errors.append("{} ERROR! Couldn't process file, error msg: {}".format(file, e)) continue card.seek(index) # Seek to the index info = card.read() card.close() lastname = "" firstname = "" personality = "" #Using regex to fetch the info try: lastnameBytes = re.search(b"lastname.{1}(.*?)\\xa9firstname", info) firstnameBytes = re.search(b"firstname.{1}(.*?)\\xa8nickname", info) personalityBytes = re.search(b"\\xabpersonality(.|\n)", info) lastname = lastnameBytes.group(1).decode("utf-8") firstname = firstnameBytes.group(1).decode("utf-8") personality = personalityTable.get(personalityBytes.group(1), None) if not personality: raise Exception("Failed to parse personality", file) except Exception as e: errors.append("{}: Had errors trying to get card info: {}".format(file, e)) continue #Renaming the card renaming = True num = 1 while(renaming): filename = f"{personality} {firstname} {lastname} {num}.png" # Edit the filename here, don't remove the {num} filename = formatName(filename) if file == filename: skippedCount += 1 renaming = False continue try: if not os.path.exists(filename): os.rename(file, filename) renaming = False print("{} -> {}".format(file, filename)) else: num += 1 except Exception as e: errors.append("{}: Had issues renaming the file! {}".format(file, e)) renaming = False print("\n") if skippedCount: print("Ignored {} properly named card(s)".format(skippedCount)) if errors: print("{} errors happened!: ".format(len(errors))) for error in errors: print(error) if __name__ == '__main__': print("Make sure this script is run in the female chara folder") print("This script targets all .png files in the folder") print("You can edit the filename in the script (line 107)") print("Default: {personality} {firstname} {lastname} {num}.png") input("\nHit ENTER to start") main() print("Finished!") input("Hit ENTER to close")