import os
import datetime

now_date = datetime.datetime.today()
now_date = datetime.datetime.strftime(now_date, '%Y%m%d%H')
root_dir = './data'
for root_path, folder, file_list in os.walk(root_dir):
    # print(root_path, folder, file_list)
    for filename in file_list:
        dt = filename.split('_')[-1][:-4]
        try:
            if int(now_date) - int(dt) > 48:
                file = os.path.join(root_path, filename)
                os.remove(file)
        except:
            continue