🧹 Massive Asset Reorganization: Cleaned filenames, removed duplicates, and sorted into UI/Items/Env/Chars/Animals folders.
This commit is contained in:
79
scripts/sort_characters_visual.py
Normal file
79
scripts/sort_characters_visual.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
SOURCE_DIR = os.path.abspath("assets/slike/glavna_referenca")
|
||||
CHAR_ROOT = os.path.join(SOURCE_DIR, "Characters")
|
||||
|
||||
# Mapping "Visual Features" to Folders
|
||||
RULES = [
|
||||
# KAI (Dredi, Pirsingi, Player)
|
||||
{
|
||||
"target": "kai",
|
||||
"keywords": ["kai", "player", "hero", "dread", "piercing", "pink_hair"]
|
||||
},
|
||||
# ANA (Sestra)
|
||||
{
|
||||
"target": "ana",
|
||||
"keywords": ["ana", "sister", "sestra", "girl", "child"]
|
||||
},
|
||||
# GRONK (Vape, Pink Dredi)
|
||||
{
|
||||
"target": "gronk",
|
||||
"keywords": ["gronk", "vape", "punk", "smoke"]
|
||||
},
|
||||
# STARŠA (Mama, Ata, Duhovi)
|
||||
{
|
||||
"target": "parents",
|
||||
"keywords": ["mom", "dad", "parent", "starse", "mama", "oce", "ghost", "spirit", "portrait", "frame"]
|
||||
},
|
||||
# NPC (Vsi ostali ljudje)
|
||||
{
|
||||
"target": "npc",
|
||||
"keywords": ["npc", "villager", "doctor", "merchant", "trader", "baker", "smith", "man", "woman", "person", "guard", "soldier", "enemy", "human"]
|
||||
},
|
||||
]
|
||||
|
||||
def sort_characters_smart():
|
||||
print("🧠 Začenjam pametno razvrščanje LIKOV v /Characters...")
|
||||
|
||||
count = 0
|
||||
# Walk only the source root (don't go into subfolders yet)
|
||||
for filename in os.listdir(SOURCE_DIR):
|
||||
if filename.startswith("."): continue
|
||||
src_path = os.path.join(SOURCE_DIR, filename)
|
||||
if os.path.isdir(src_path): continue
|
||||
|
||||
lower_name = filename.lower()
|
||||
target_subfolder = None
|
||||
|
||||
# Check rules
|
||||
for rule in RULES:
|
||||
if any(k in lower_name for k in rule["keywords"]):
|
||||
target_subfolder = rule["target"]
|
||||
break # Found a match, stop specific rules
|
||||
|
||||
# Move if match found
|
||||
if target_subfolder:
|
||||
dest_dir = os.path.join(CHAR_ROOT, target_subfolder)
|
||||
dest_path = os.path.join(dest_dir, filename)
|
||||
|
||||
# Create subfolder if missing for some reason
|
||||
if not os.path.exists(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
|
||||
# Handle collision
|
||||
if os.path.exists(dest_path):
|
||||
name, ext = os.path.splitext(filename)
|
||||
c = 1
|
||||
while os.path.exists(os.path.join(dest_dir, f"{name}_{c}{ext}")):
|
||||
c += 1
|
||||
dest_path = os.path.join(dest_dir, f"{name}_{c}{ext}")
|
||||
|
||||
shutil.move(src_path, dest_path)
|
||||
count += 1
|
||||
# print(f" 👤 {filename} -> Characters/{target_subfolder}")
|
||||
|
||||
print(f"✨ Premaknil sem {count} slik likov v mapo Characters!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sort_characters_smart()
|
||||
Reference in New Issue
Block a user