Thursday, 17 May 2012

Decimating (and more) CFD results with Python

This two liner removes all time directories for times smaller than 0.1ms. It's native Python. import os, shutil d = '/home/me/CFD/tilt3D_9/p50'; a = os.listdir(d); b = [i for i in a if len(i) in [7,8] and i[0] in ['0','1','2','3','4','5','6','7','8','9']]; [shutil.rmtree(d + '/' + i) for i in b]

No comments:

Post a Comment