arcadiaaaaa
Add files using upload-large-folder tool
24303c9 verified
Raw History Blame Contribute Delete
1.55 kB
import os
import shutil
from tqdm import tqdm
def main():
old_prefix = '/home/rcell/genshin_data/'
new_prefix = '/home/rcell/data/magvits_data/'
file_list_path = '/home/rcell/data/magvits_reborn/dump/val_files_gs.list'
extensions = ['.latent.pt', '.lab', '.spk.npy', '.ssl.pt']
# 读取文件列表
with open(file_list_path, 'r') as f:
wav_files = [line.strip() for line in f if line.strip()]
for src_wav in tqdm(wav_files):
if not src_wav.startswith(old_prefix):
print(f"Warning: Path {src_wav} doesn't start with {old_prefix}")
continue
# 生成目标路径
dest_wav = src_wav.replace(old_prefix, new_prefix, 1)
dest_dir = os.path.dirname(dest_wav)
# 创建目标目录
os.makedirs(dest_dir, exist_ok=True)
# 复制原始wav文件
try:
shutil.copy2(src_wav, dest_wav)
except FileNotFoundError:
print(f"源文件不存在: {src_wav}")
continue
# 处理扩展文件
assert src_wav.endswith('.wav'), "源文件必须以.wav结尾"
base_name = src_wav[:-4] # 去掉.wav后缀
for ext in extensions:
src_file = f"{base_name}{ext}"
dest_file = os.path.join(dest_dir, os.path.basename(src_file))
try:
shutil.copy2(src_file, dest_file)
except FileNotFoundError:
print(f"扩展文件不存在: {src_file}")
if __name__ == "__main__":
main()