python: File Size Watcher
Tested.
In use at work.
This quick script will watch the size of a file. It will console print the file name and file size. I may also add an optional argument to display the last line of the file.
import os
import sys
import time
if len(sys.argv) == 1:
print ""
print "You gots to give me a file to watch the size of..."
print ""
print " me.py c:\\filetowatchsizeof.txt"
print ""
print ""
print "--hit enter to exit--"
raw_input()
else:
linearg = sys.argv[1]
while True:
os.system(['clear','cls'][os.name == 'nt'])
filesize=os.path.getsize(linearg)
print "Updating every 60 seconds"
print "WATCHING: " + str(linearg)
print ""
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + ": " + str(filesize) + " bytes OR " + str(filesize/1048576) + " MB"
time.sleep(60)
In use at work.
This quick script will watch the size of a file. It will console print the file name and file size. I may also add an optional argument to display the last line of the file.
import os
import sys
import time
if len(sys.argv) == 1:
print ""
print "You gots to give me a file to watch the size of..."
print ""
print " me.py c:\\filetowatchsizeof.txt"
print ""
print ""
print "--hit enter to exit--"
raw_input()
else:
linearg = sys.argv[1]
while True:
os.system(['clear','cls'][os.name == 'nt'])
filesize=os.path.getsize(linearg)
print "Updating every 60 seconds"
print "WATCHING: " + str(linearg)
print ""
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + ": " + str(filesize) + " bytes OR " + str(filesize/1048576) + " MB"
time.sleep(60)
0 Comments:
Post a Comment
<< Home