mhm
This commit is contained in:
76
scripts/organize_strict_two_folders.py
Normal file
76
scripts/organize_strict_two_folders.py
Normal file
@@ -0,0 +1,76 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
ROOT_DIR = os.path.abspath("assets/slike/glavna_referenca")
|
||||
NPC_DIR = os.path.join(ROOT_DIR, "NPC_CHARACTERS")
|
||||
BUILD_DIR = os.path.join(ROOT_DIR, "BUILDINGS")
|
||||
|
||||
# Keywords for NPC/Characters
|
||||
KEYW_NPC = [
|
||||
"kai", "ana", "gronk", "susi", "player", "liki", "hero", # Main
|
||||
"npc", "zombie", "skeleton", "enemy", "boss", "mob", # Enemies
|
||||
"villager", "trader", "merchant", "blacksmith", # Town NPCs
|
||||
"baker", "scientist", "priest", "druid", "witch", # Special NPCs
|
||||
"hunter", "guide", "mayor", "doctor", "soldier",
|
||||
"character", "person", "human", "face", "portrait"
|
||||
]
|
||||
|
||||
# Keywords for Buildings
|
||||
KEYW_BUILD = [
|
||||
"house", "home", "hut", "tent", "cabin", "shack", # Residential
|
||||
"shop", "market", "store", "inn", "tavern", # Commercial
|
||||
"barn", "shed", "farmhouse", "silo", "mill", # Farm
|
||||
"castle", "tower", "fort", "wall", "gate", # Defense
|
||||
"ruin", "temple", "shrine", "monument", # Structures
|
||||
"building", "structure", "architecture", "gradnja",
|
||||
"objekti", "furniture", "bed", "table" # Interior/Furniture often goes with building
|
||||
]
|
||||
|
||||
def organize_strict():
|
||||
if not os.path.exists(ROOT_DIR):
|
||||
return
|
||||
|
||||
for d in [NPC_DIR, BUILD_DIR]:
|
||||
if not os.path.exists(d):
|
||||
os.makedirs(d)
|
||||
|
||||
print(f"📦 Organizing into NPC_CHARACTERS and BUILDINGS...")
|
||||
|
||||
count_npc = 0
|
||||
count_build = 0
|
||||
|
||||
for filename in os.listdir(ROOT_DIR):
|
||||
if filename.startswith("."): continue
|
||||
if os.path.isdir(os.path.join(ROOT_DIR, filename)): continue # Skip directories
|
||||
|
||||
src = os.path.join(ROOT_DIR, filename)
|
||||
lower = filename.lower()
|
||||
dest_folder = None
|
||||
|
||||
# Priority 1: Characters
|
||||
if any(k in lower for k in KEYW_NPC):
|
||||
dest_folder = NPC_DIR
|
||||
count_npc += 1
|
||||
# Priority 2: Buildings
|
||||
elif any(k in lower for k in KEYW_BUILD):
|
||||
dest_folder = BUILD_DIR
|
||||
count_build += 1
|
||||
|
||||
if dest_folder:
|
||||
dest = os.path.join(dest_folder, filename)
|
||||
# Handle duplicates
|
||||
if os.path.exists(dest):
|
||||
base, ext = os.path.splitext(filename)
|
||||
c = 1
|
||||
while os.path.exists(os.path.join(dest_folder, f"{base}_{c}{ext}")):
|
||||
c += 1
|
||||
dest = os.path.join(dest_folder, f"{base}_{c}{ext}")
|
||||
|
||||
shutil.move(src, dest)
|
||||
|
||||
print(f"✨ DONE!")
|
||||
print(f"👤 NPC/CHARACTERS: Moved {count_npc} images")
|
||||
print(f"🏠 BUILDINGS: Moved {count_build} images")
|
||||
|
||||
if __name__ == "__main__":
|
||||
organize_strict()
|
||||
Reference in New Issue
Block a user