#!/usr/bin/env python3 import os import shutil import os from pathlib import Path IN="./raw" OUT="./raw_good" GOOD = None with open('./good.txt', 'r') as f: GOOD = list(map(str.strip, f.readlines())) wav_files = [] for root, _, files in os.walk(IN): for file in files: if not (file.endswith('.wav') and file[:-4] in GOOD): continue src = Path(os.path.join(root, file)) dst_name = Path(OUT) / src.name shutil.move(src, dst_name)