File size: 1,077 Bytes
ed552fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""清理 raw/ 下所有 case 的中间时间步、log、processor、postProcessing,
只保留 0/ constant/ system/ Allrun Allclean(初始条件和配置)"""
import os, shutil

raw = '/mnt/f/agent-workspace/paper2/Exp/data/raw'
keep = {'0', 'constant', 'system', 'Allrun', 'Allclean'}
total_removed = 0

for ct in sorted(os.listdir(raw)):
    ct_dir = os.path.join(raw, ct)
    if not os.path.isdir(ct_dir):
        continue
    for case in sorted(os.listdir(ct_dir)):
        case_dir = os.path.join(ct_dir, case)
        if not os.path.isdir(case_dir):
            continue
        for entry in os.listdir(case_dir):
            if entry in keep:
                continue
            path = os.path.join(case_dir, entry)
            try:
                if os.path.isdir(path):
                    shutil.rmtree(path)
                else:
                    os.remove(path)
                total_removed += 1
            except Exception as e:
                print(f'  WARN: {path}: {e}')

print(f'Cleaned {total_removed} entries from {raw}')