Skip to content

Instantly share code, notes, and snippets.

@josephzjw
Created September 20, 2019 07:06
Show Gist options
  • Save josephzjw/200890066e7690dd00c39eabede58548 to your computer and use it in GitHub Desktop.
Save josephzjw/200890066e7690dd00c39eabede58548 to your computer and use it in GitHub Desktop.
test
import os
import shutil
# import time
#
# year_month_day = time.strptime("2019 12 31", "%Y %m %d")
# print(year_month_day)
# def write_wav(tmp_name):
# with open(tmp_name, 'w') as f:
# f.write('file test')
# for i in range(101):
# tmp_path = os.path.join(root_path, f'{i:03d}.wav')
# write_wav(tmp_path)
root_path = 'wav_origin' # suppose the origin wave files are in this directory
extract_path = 'wav_extract' # suppose the extract wave files are in this directory
extract_file_num = ['7', '8'] # suppose the extract wave files end with these
if not os.path.exists(extract_path):
os.makedirs(extract_path)
origin_files_list = os.listdir(root_path)
files_to_copy = filter(lambda x: os.path.splitext(x)[0][-1] in extract_file_num, origin_files_list)
for i in files_to_copy:
src_path = os.path.join(root_path, i)
target_path = os.path.join(extract_path, i)
shutil.copyfile(src_path, target_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment