Skip to content

Commit

Permalink
add pfem cleaning script
Browse files Browse the repository at this point in the history
  • Loading branch information
rboman committed Oct 6, 2023
1 parent 1d2a72a commit 2679af3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bin/rm_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf8 -*-
# clean pfem workspaces

import os, glob, re

# folder = 'CylinderRiseOil_CylinderRiseSmall_Re50'
folder = 'FlowAroundCylinderRe200_LargeMeshRef1'
os.chdir(folder)

# build and sort res files
files = glob.glob('res_*.vtu')
nfiles=len(files)
print(f'nfiles={nfiles}')
def file_time(f):
m = re.match(r'res_(\d+).vtu', f)
return int(m.group(1))
files.sort(key=file_time)

if 0:
# delete the "delete_to" first files
delete_to = 1700

for i,f in enumerate(files[:delete_to]):
fullpath = os.path.abspath(os.path.join(folder,f))
print(f'{i+1}: rm {fullpath}')
os.remove(f)

if 0:
# delete the files from "delete_from"
delete_from = 500

for i,f in enumerate(files[delete_from:]):
fullpath = os.path.abspath(os.path.join(folder,f))
print(f'{i+1}: rm {fullpath}')
os.remove(f)

0 comments on commit 2679af3

Please sign in to comment.