#! /usr/bin/python # USAGE: Masfs_rename.py # PURPOSE: Renames the accumulating Loggernet Collection files from ASFS, time stamps and moves to archive # AUTHOR: Chris Cox (CIRES, NOAA/PSD) import os, datetime, shutil # get the time thetime = datetime.datetime.now() # this code is run 4 minutes after the last collection, so subtract the 4 min thetime = thetime - datetime.timedelta(minutes=4) # new time, formatted newtime = thetime.strftime("%m%d%Y"+"_"+"%H%M") # ASFS 30 try: old_name = 'D:/asfs30/ASFS_30_fast.dat' new_name = 'D:/asfs30/daily_files/ASFS_30_fast_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs30/ASFS_30_met.dat' new_name = 'D:/asfs30/daily_files/ASFS_30_met_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs30/ASFS_30_slow.dat' new_name = 'D:/asfs30/daily_files/ASFS_30_slow_'+newtime+'.dat' shutil.move(old_name,new_name) except: print('No file to move') # ASFS 40 try: old_name = 'D:/asfs40/ASFS_40_fast.dat' new_name = 'D:/asfs40/daily_files/ASFS_40_fast_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs40/ASFS_40_met.dat' new_name = 'D:/asfs40/daily_files/ASFS_40_met_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs40/ASFS_40_slow.dat' new_name = 'D:/asfs40/daily_files/ASFS_40_slow_'+newtime+'.dat' shutil.move(old_name,new_name) except: print('No file to move') # ASFS 50 try: old_name = 'D:/asfs50/ASFS_50_fast.dat' new_name = 'D:/asfs50/daily_files/ASFS_50_fast_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs50/ASFS_50_met.dat' new_name = 'D:/asfs50/daily_files/ASFS_50_met_'+newtime+'.dat' shutil.move(old_name,new_name) old_name = 'D:/asfs50/ASFS_50_slow.dat' new_name = 'D:/asfs50/daily_files/ASFS_50_slow_'+newtime+'.dat' shutil.move(old_name,new_name) except: print('No file to move')