What I would like to do is to check the size of an archive directory in each of our users folders accessible via a Windows machine. I have a txt file with all of the users names (1 per line) and am trying to use for loops and potentially readline to iterate over the file and us os.path.walk to determine the size. I have confirmed that my syntax for 1 directory work, but when I try to iterate, it does not work. Also, when printing the value of the path for each iteration I get the first part on one line and then the last part of the path on another. Please help with the syntax. Below is where I have left off:
# This script will determine the size if the gwarchive directories in everyone's home folder
import os
import fileinput
folder_size = 0
for username in fileinput.input("L:\\dirl.txt"):
folder = ("L:\\" + (username) + "\gwarchiv")
print folder
for (path, dirs, files) in os.walk(folder):
for name in files:
filename = os.path.join(path, name)
folder_size += os.path.getsize(filename)
print "Archive = %0.1f MB" % (folder_size/(1024*1024.0))