ok
This commit is contained in:
52
scripts/sort_notes.py
Normal file
52
scripts/sort_notes.py
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import re
|
||||
|
||||
TARGET = "assets/slike/glavna_referenca"
|
||||
|
||||
RULES = [
|
||||
(r"(rabbit|sheep|cow|pig|bear|wolf|dog|cat|goat|llama|deer|ant|insect|zival|animal|zajec|ovca|krava|pes|macka)", "Zivali"),
|
||||
(r"(house|building|wall|ruin|barn|farm|church|tower|shop|store|zgradba|hisa|hiša)", "Zgradbe"),
|
||||
(r"(kai|ana|gronk|npc|man|woman|boy|girl|farmer|merchant|priest|character|oseba)", "NPCs"),
|
||||
(r"(zombie|undead|monster|boss|kreatura|zombi)", "Kreature"),
|
||||
(r"(tree|bush|flower|plant|crop|rastlina|drevo)", "Rastline"),
|
||||
(r"(item|tool|weapon|food|predmet|orodje)", "Predmeti"),
|
||||
(r"(grass|ground|water|stone|tile|teren|tla)", "Teren")
|
||||
]
|
||||
|
||||
def sort_notes():
|
||||
print(f"🚀 SORTING NOTES (.md, .txt) in {TARGET}...")
|
||||
|
||||
if not os.path.exists(TARGET):
|
||||
return
|
||||
|
||||
for filename in os.listdir(TARGET):
|
||||
if not os.path.isfile(os.path.join(TARGET, filename)):
|
||||
continue
|
||||
|
||||
# Target only text files
|
||||
if not filename.lower().endswith(('.md', '.txt', '.json', '.xml')):
|
||||
continue
|
||||
|
||||
fname_lower = filename.lower()
|
||||
target_sub = "_DOKUMENTACIJA" # Default for notes
|
||||
|
||||
# Try to match context
|
||||
for pattern, folder in RULES:
|
||||
if re.search(pattern, fname_lower):
|
||||
target_sub = folder
|
||||
break
|
||||
|
||||
dest_dir = os.path.join(TARGET, target_sub)
|
||||
if not os.path.exists(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
|
||||
try:
|
||||
shutil.move(os.path.join(TARGET, filename), os.path.join(dest_dir, filename))
|
||||
print(f"📄 Moved {filename} -> {target_sub}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sort_notes()
|
||||
Reference in New Issue
Block a user