70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
|
|
import os
|
|
import shutil
|
|
import re
|
|
|
|
ROOT = "assets/slike"
|
|
PHASES = {
|
|
"DEMO": [r"demo", r"0_demo", r"phase_0"],
|
|
"FAZA_1": [r"faza_1", r"faza1", r"phase_1", r"phase1"],
|
|
"FAZA_2": [r"faza_2", r"faza2", r"phase_2", r"phase2"]
|
|
}
|
|
CATEGORIES = ["teren", "liki", "animations", "predmeti", "MASTER_REFS"]
|
|
|
|
def sort_phases():
|
|
print("🚀 SORTING BY PHASE (DEMO, FAZA 1, FAZA 2)...")
|
|
|
|
# Create Phase Folders
|
|
for phase in PHASES:
|
|
p_path = os.path.join(ROOT, phase)
|
|
if not os.path.exists(p_path):
|
|
os.makedirs(p_path)
|
|
print(f"📁 Created: {p_path}")
|
|
|
|
moved_count = 0
|
|
|
|
for category in CATEGORIES:
|
|
src_cat_path = os.path.join(ROOT, category)
|
|
if not os.path.exists(src_cat_path):
|
|
continue
|
|
|
|
print(f"🔍 Scanning {category}...")
|
|
|
|
for filename in os.listdir(src_cat_path):
|
|
if not filename.lower().endswith(('.png', '.jpg', '.jpeg')):
|
|
continue
|
|
|
|
fname_lower = filename.lower()
|
|
target_phase = None
|
|
|
|
# Identify Phase
|
|
for phase, keywords in PHASES.items():
|
|
for kw in keywords:
|
|
if kw in fname_lower:
|
|
target_phase = phase
|
|
break
|
|
if target_phase:
|
|
break
|
|
|
|
if target_phase:
|
|
# Move to assets/slike/PHASE/Category/
|
|
dest_folder = os.path.join(ROOT, target_phase, category)
|
|
if not os.path.exists(dest_folder):
|
|
os.makedirs(dest_folder)
|
|
|
|
src_path = os.path.join(src_cat_path, filename)
|
|
dest_path = os.path.join(dest_folder, filename)
|
|
|
|
try:
|
|
shutil.move(src_path, dest_path)
|
|
moved_count += 1
|
|
except Exception as e:
|
|
print(f"❌ Error moving {filename}: {e}")
|
|
|
|
print("="*40)
|
|
print(f"✅ SORTING COMPLETE. Moved {moved_count} images.")
|
|
print("="*40)
|
|
|
|
if __name__ == "__main__":
|
|
sort_phases()
|