organization script

This commit is contained in:
Vysyr committed 2026-09-04 23:42:07 +02:00
1 parent becfbb3c46
commit c448623471
2 files changed
+44

No files matched your search

File renamed without changes.
+44
View File
@@ -0,0 +1,44 @@
import re, unreal
FOLDERS = {
"material": "Materials",
"player": "Characters/Player",
"enemy": "Characters/Enemy",
"particle": "Effects",
}
CLASS_FOLDERS = {
"World": "Maps",
"LevelSequence": "Sequences",
}
PREFIXES = {
"World": "",
"Material": "M_",
"MaterialInstanceConstant": "MI_",
"StaticMesh": "SM_",
"SkeletalMesh": "SK_",
"Blueprint": "BP_",
"NiagaraSystem": "NS_",
"LevelSequence": "LS_",
}
lib = unreal.EditorAssetLibrary
for path in lib.list_assets("/Game", recursive=True):
path = path.split(".")[0]
name = path.rsplit("/", 1)[-1]
data = lib.find_asset_data(path)
cls = str(data.asset_class_path.asset_name)
# instance assets are renamed after their parent, not their own name
if cls == "MaterialInstanceConstant":
parent = lib.load_asset(path).get_editor_property("parent")
base = re.sub(r"^(M_|MI_)", "", parent.get_name()) if parent else name
suffix = name[len(base):] if name.lower().startswith(base.lower()) else ""
name = base + (f"_{suffix.capitalize()}" if suffix else "")
name = re.sub(r"^(" + "|".join(p for p in PREFIXES.values() if p) + ")", "", name)
name = PREFIXES.get(cls, "") + name
folder = CLASS_FOLDERS.get(cls) or next((f for k, f in FOLDERS.items() if k in name.lower()), "Misc")
dest = f"/Game/{folder}/{name}"
if path != dest:
lib.rename_asset(path, dest)