This commit is contained in:
2026-01-20 17:22:42 +01:00
parent cce5ed9791
commit ae1cf2e9bf
4777 changed files with 280 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
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()

View 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()

View File

@@ -0,0 +1,65 @@
import os
import hashlib
import shutil
TARGET_DIR = os.path.abspath("assets/slike/glavna_referenca")
TRASH_DIR = os.path.abspath("_TRASH_BIN/duplicates_referenca")
def get_file_hash(filepath):
"""Calculates MD5 hash of file content."""
hasher = hashlib.md5()
try:
with open(filepath, 'rb') as f:
buf = f.read(65536)
while len(buf) > 0:
hasher.update(buf)
buf = f.read(65536)
return hasher.hexdigest()
except:
return None
def remove_duplicates():
if not os.path.exists(TARGET_DIR):
print("❌ Target directory not found.")
return
if not os.path.exists(TRASH_DIR):
os.makedirs(TRASH_DIR)
print(f"🔍 Scanning for exact duplicates in {TARGET_DIR}...")
unique_hashes = {} # hash -> filepath
duplicates = 0
scanned = 0
files = [f for f in os.listdir(TARGET_DIR) if os.path.isfile(os.path.join(TARGET_DIR, f)) and not f.startswith(".")]
total_files = len(files)
for filename in files:
filepath = os.path.join(TARGET_DIR, filename)
file_hash = get_file_hash(filepath)
if file_hash:
if file_hash in unique_hashes:
# Duplicate found!
original = unique_hashes[file_hash]
# Move to trash
shutil.move(filepath, os.path.join(TRASH_DIR, filename))
duplicates += 1
# Optional: Print info
# print(f"Duplicate: {filename} == {os.path.basename(original)}")
else:
# New unique file
unique_hashes[file_hash] = filepath
scanned += 1
if scanned % 500 == 0:
print(f" Scanned {scanned}/{total_files} files...")
print(f"✨ DONE! Found and moved {duplicates} duplicates to {TRASH_DIR}")
print(f"✅ Unique files remaining: {len(unique_hashes)}")
if __name__ == "__main__":
remove_duplicates()

65
scripts/remove_targets.py Normal file
View File

@@ -0,0 +1,65 @@
import os
import hashlib
import shutil
TARGET_DIR = os.path.abspath("assets/slike/glavna_referenca")
SAMPLE_DIR = os.path.abspath("_TRASH_SAMPLES")
TRASH_DIR = os.path.abspath("_TRASH_BIN/targeted_cleanup")
def get_file_hash(filepath):
hasher = hashlib.md5()
try:
with open(filepath, 'rb') as f:
buf = f.read(65536)
while len(buf) > 0:
hasher.update(buf)
buf = f.read(65536)
return hasher.hexdigest()
except:
return None
def main():
if not os.path.exists(SAMPLE_DIR):
print("❌ Sample directory missing.")
return
if not os.path.exists(TRASH_DIR):
os.makedirs(TRASH_DIR)
# 1. Get hashes of samples
print(f"🎯 analyzing samples in {SAMPLE_DIR}...")
target_hashes = set()
for f in os.listdir(SAMPLE_DIR):
if f.startswith("."): continue
h = get_file_hash(os.path.join(SAMPLE_DIR, f))
if h:
target_hashes.add(h)
print(f"🎯 Loaded {len(target_hashes)} unique target signatures.")
# 2. Scan and destroy
print(f"🔍 Scanning {TARGET_DIR} for matches...")
count = 0
matches = 0
for root, dirs, files in os.walk(TARGET_DIR):
for filename in files:
if filename.startswith("."): continue
filepath = os.path.join(root, filename)
file_hash = get_file_hash(filepath)
if file_hash in target_hashes:
# MATCH FOUND!
# print(f"💥 Destroying: {filename}")
shutil.move(filepath, os.path.join(TRASH_DIR, filename))
matches += 1
count += 1
if count % 1000 == 0:
print(f" Scanned {count} files...")
print(f"✨ DONE! Removed {matches} matching files to {TRASH_DIR}")
if __name__ == "__main__":
main()