import os
import fnmatch

files = ["1", "65", "73", "81", "87", "95", "103", "111"]
path = "D:\\HKUST\\beat_english_v0.2.1\\BEAT"

print(os.listdir(path))

# Iterate through the directories indicated by the numbers in the files list
for dir_number in range(1,31):
    # Construct the path to the current directory
    current_dir_path = os.path.join(path, str(dir_number))

    # Check if the directory exists before attempting to list its contents
    if os.path.isdir(current_dir_path):
        # List all files in the current directory
        for filename in os.listdir(current_dir_path):
            # Check if the file ends with "1_1.bvh"
            for num in files:
                if fnmatch.fnmatch(filename, "*"+num+"_"+num+".bvh"):
                    # Construct the full path to the file
                    full_file_path = os.path.join(current_dir_path, filename)
                    # Output the full path or process the file as needed
                    os.system("copy "+full_file_path+" "+os.path.join(path, "samples"))
