File size: 439 Bytes
d66e21a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json
import os

if __name__ == "__main__":
    base = "train/"
    with open(base+'metadata.jsonl', 'r') as f:
        metadata = [json.loads(line) for line in f]

    file_names = [item['file_name'] for item in metadata]
    file_names.append("metadata.jsonl")

    all_files = os.listdir('train')

    for file in all_files:
        if file not in file_names:
            print("Removing:", file)
            os.remove(base+file)