Created
September 20, 2019 07:06
-
-
Save josephzjw/200890066e7690dd00c39eabede58548 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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