75 lines
2.4 KiB
Python
75 lines
2.4 KiB
Python
import os
|
|
import shutil
|
|
|
|
ROOT_DIR = os.path.abspath("assets/slike/glavna_referenca")
|
|
BUILDINGS_DIR = os.path.join(ROOT_DIR, "buildings")
|
|
CHARACTERS_DIR = os.path.join(ROOT_DIR, "characters")
|
|
|
|
# Keywords for categorization
|
|
CHAR_KEYWORDS = [
|
|
"kai", "ana", "gronk", "susi",
|
|
"npc", "character", "enemy", "zombie", "boss", "skeleton",
|
|
"druid", "witch", "merchant", "trader", "scientist",
|
|
"baker", "blacksmith", "priest", "guide", "hunter",
|
|
"chief", "pharaoh", "stalker", "liki", "player"
|
|
]
|
|
|
|
BUILD_KEYWORDS = [
|
|
"building", "house", "home", "hut", "tent",
|
|
"shop", "store", "market", "stall",
|
|
"wall", "structure", "ruin", "barn", "shed",
|
|
"tower", "castle", "temple", "shrine", "cabin",
|
|
"objekti", "gradnja", "hisa"
|
|
]
|
|
|
|
def organize_v2():
|
|
if not os.path.exists(ROOT_DIR):
|
|
print("❌ Root folder not found.")
|
|
return
|
|
|
|
# Create dirs
|
|
for d in [BUILDINGS_DIR, CHARACTERS_DIR]:
|
|
if not os.path.exists(d):
|
|
os.makedirs(d)
|
|
|
|
print(f"📦 Organizing {ROOT_DIR} into Buildings & Characters...")
|
|
|
|
moved_chars = 0
|
|
moved_builds = 0
|
|
|
|
for filename in os.listdir(ROOT_DIR):
|
|
if filename.startswith("."): continue
|
|
if os.path.isdir(os.path.join(ROOT_DIR, filename)): continue # Skip folders
|
|
|
|
src_path = os.path.join(ROOT_DIR, filename)
|
|
lower_name = filename.lower()
|
|
dest_dir = None
|
|
|
|
# Check Characters FIRST (Priority)
|
|
if any(k in lower_name for k in CHAR_KEYWORDS):
|
|
dest_dir = CHARACTERS_DIR
|
|
moved_chars += 1
|
|
# Check Buildings SECOND
|
|
elif any(k in lower_name for k in BUILD_KEYWORDS):
|
|
dest_dir = BUILDINGS_DIR
|
|
moved_builds += 1
|
|
|
|
if dest_dir:
|
|
dest_path = os.path.join(dest_dir, filename)
|
|
# Handle duplicates
|
|
if os.path.exists(dest_path):
|
|
base, ext = os.path.splitext(filename)
|
|
counter = 1
|
|
while os.path.exists(os.path.join(dest_dir, f"{base}_{counter}{ext}")):
|
|
counter += 1
|
|
dest_path = os.path.join(dest_dir, f"{base}_{counter}{ext}")
|
|
|
|
shutil.move(src_path, dest_path)
|
|
|
|
print(f"✨ DONE!")
|
|
print(f"👤 Moved {moved_chars} to /characters")
|
|
print(f"🏠 Moved {moved_builds} to /buildings")
|
|
|
|
if __name__ == "__main__":
|
|
organize_v2()
|