File size: 1,506 Bytes
815dacb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import shutil
import time

script_dir = os.path.dirname(os.path.abspath(__file__))

# Use the correct folder names (train_0, train_1, train_2)
source_folders = ["./train_splits/train_0", "./train_splits/train_1", "./train_splits/train_2"]
dest_dir = os.path.join(script_dir, "train")

os.makedirs(dest_dir, exist_ok=True)

copied = skipped = errors = 0
start = time.time()

print(f"Script directory: {script_dir}")
print(f"Destination folder: {dest_dir}")
print("Starting copy process...\n")

for relative in source_folders:
    src_path = os.path.join(script_dir, relative)
    base_name = os.path.basename(relative)

    if not os.path.isdir(src_path):
        print(f"Skipping missing folder: {src_path}")
        continue

    print(f"Processing folder: {src_path}")

    for fname in os.listdir(src_path):
        if not fname.lower().endswith(".wav"):
            continue

        src_file = os.path.join(src_path, fname)
        dest_file = os.path.join(dest_dir, f"{fname}")

        if os.path.exists(dest_file):
            skipped += 1
            continue

        try:
            shutil.copy2(src_file, dest_file)
            copied += 1
            if copied % 100 == 0:
                print(f"Copied {copied} files so far...")
        except Exception as e:
            print(f"Failed to copy {src_file}: {e}")
            errors += 1

duration = time.time() - start
print(f"\nCopied: {copied}, Skipped: {skipped}, Errors: {errors}")
print(f"Time taken: {duration:.2f} seconds")