This problem came up in one thread and here is my finalised version to follow changes of files in list of paths given.
Watch for change of files in directories
import os,time
path_list=['/Python Projects','/Python26',
'/Python26/Lib','/Python26/Lib/site-packages']
path_list=[os.path.realpath(p) for p in path_list]
def files(path_list):
fileset=set()
for path_to_watch in path_list:
for f in os.listdir(path_to_watch):
fileset.add(os.path.join(path_to_watch,f))
return fileset
while 'Allways':
before=files(path_list)
time.sleep (3)
after=files(path_list)
if after != before:
added = ",".join(after-before)
removed = ",".join(before-after)
print 'Added: %s\nRemoved: %s\n' % (added,removed)
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.