| |
| """Build ../character_refined/: a complete 114-character set where corrupted |
| 'mixamorig<N>:' bone namespaces are renamed to 'mixamorig:'. |
| Unchanged characters are hardlinked, so only the fixed files cost disk. |
| Originals in ../character/ are never modified.""" |
| import os, re, sys, shutil |
| HERE=os.path.dirname(os.path.abspath(__file__)); sys.path.insert(0,HERE) |
| from fbx_rename_bones import process, RENAME |
|
|
| SRC=os.path.join(os.path.dirname(HERE),"character") |
| DST=os.path.join(os.path.dirname(HERE),"character_refined") |
| os.makedirs(DST,exist_ok=True) |
| fixed=[]; linked=[]; failed=[] |
| files=sorted(f for f in os.listdir(SRC) if f.endswith(".fbx")) |
| for i,f in enumerate(files,1): |
| s=os.path.join(SRC,f); d=os.path.join(DST,f) |
| if os.path.exists(d): continue |
| blob=open(s,"rb").read() |
| if RENAME.search(blob): |
| try: |
| n,_,_ = process(s,d,do_edit=True) |
| fixed.append((f,n)) |
| print(" [%3d/114] FIXED %-26s %d strings"%(i,f,n),flush=True) |
| except Exception as e: |
| failed.append((f,str(e)[:60])); print(" [%3d/114] ERROR %s: %s"%(i,f,e),flush=True) |
| else: |
| try: os.link(s,d) |
| except OSError: shutil.copy2(s,d) |
| linked.append(f) |
| print("\nfixed: %d | hardlinked unchanged: %d | failed: %d"%(len(fixed),len(linked),len(failed))) |
| for f,e in failed: print(" FAILED",f,e) |
|
|