-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_move_output_files.py
37 lines (31 loc) · 1.33 KB
/
create_move_output_files.py
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
import os, sys
from datetime import datetime
import shutil
import fnmatch
wrk_dir = r"/data/keeling/a/sf20/b/WRF4_4/WRF/test/em_les"
output_dir = r"/data/nriemer/d/sf20/les_output"
now = datetime.now()
datestamp = now.strftime('%Y-%m-%d')
timestamp = datetime.now().strftime('%H%M%S')
output_path = os.path.join(output_dir, datestamp, timestamp)
if not os.path.isdir(output_path):
os.makedirs(output_path)
print(f'{output_path}')
error_files = fnmatch.filter(os.listdir('.'), "rsl.error.*")
out_files = fnmatch.filter(os.listdir('.'), "rsl.out.*")
slurm_files = fnmatch.filter(os.listdir('.'), "slurm-*.out*")
wrfinput_files = fnmatch.filter(os.listdir('.'), "wrfinput_*")
wrfoutput_files = fnmatch.filter(os.listdir('.'), "wrfout_*")
wrfrst_files = fnmatch.filter(os.listdir('.'), "wrfrst_*")
namelist_output = fnmatch.filter(os.listdir('.'), "namelist.output")
species_config_files = fnmatch.filter(os.listdir('.'), "species_*data.json")
move_files = (error_files + out_files + slurm_files + wrfinput_files
+ wrfoutput_files + wrfrst_files + namelist_output
+ species_config_files)
if len(move_files) == 0:
print('No files to move, exiting')
sys.exit()
print('Moving simulation files')
for file in move_files:
shutil.move(f"{wrk_dir}/{file}", f"{output_path}/{file}")
# TODO: could also move wrfchemi files