|
Answer» HELLO FRIENDS
i want to count number of files according to the date and then in between the time interval in the windows file system and save the out put in the text file with details like this
date time interval count =========================================
30/03/2010 0200-0400 900 30/03/2010 0400-0600 897 ................. ------- -- 30/03/2010 2200-2400 785
Waiting for Your replies
bye for now here's a Python script.
Code: [SELECT]IMPORT os import time results={} path = os.path.join("c:\\","test") output=os.path.join("c:\\","test","output.txt") o=open(output,"w") o.write("date\t\ttime_intervale\t\tcount\n") for R,d,f in os.walk(path): for files in f: fpath=os.path.join(r,files) mtime = time.localtime(os.path.getmtime(fpath)) file_date = time.strftime("%m/%d/%Y",mtime) file_time = int(time.strftime("%H%M",mtime)) tag="" if file_time >= 200 and file_time <400: tag="\t200-400" elif file_time >= 400 and file_time <600: tag="\t400-600" elif file_time >= 800 and file_time <1000: tag="\t800-1000" elif file_time >= 1000 and file_time <1200: tag="\t1000-1200" elif file_time >= 1200 and file_time <1400: tag="\t1200-1400" elif file_time >= 1400 and file_time <1600: tag="\t1400-1600" if tag: results.setdefault(file_date+tag,0) results[file_date+tag]+=1
for key in sorted(results.keys()): print key,results[key] o.write(key + "\t"+str(results[key]) + "\n") o.close()
save as myscript.py and on COMMAND line,
Code: [Select]c:\test> python myscript.py add the rest of the time as needed
|