代码合集(2020)

Uasset 转 Wav

# 本程序用于提取在虚幻引擎商城购买的音效包,请按需修改,请勿随意传播提取结果
import os
d1=r'D:\Unreal Projects\Rooftile\Content\8bit16bitSoundFX\SoundWav\\' # \\结尾
d2=r'D:\Unreal Projects\Rooftile\Content\8bit16bitSoundFX\wav\\'
for  n0 in os.listdir(d1):
 for n1 in os.listdir(d1+n0+'\\'):
  ua='-Audio.uasset'
  if len(n1)<len(ua) or n1[-len(ua):]!=ua: continue
  n2=n1[:-len(ua)]+'.wav'
  with  open(d1+n0+'\\'+n1,'rb') as f1:
   with open(d2        +n2,'wb') as f2:
    c1=f1.read(); c2=c1[c1.find(b'WAVEfmt'):-4]
    f2.write(b'RIFF'+len(c2).to_bytes(4,'little')+c2)
    print('%s OK'%n2)
print('-ENTER-');input()