I generate an array from the folders in a directory; which is placed in an array. i then compare it for changes in the currant folder.This way i can monitor for new files that are add to the system and trigger the script.
but i am having problems comparing the array against the currant files. my code looks like this.
import time import os path_to_watch =  path_to_watch.append("/folder1/") path_to_watch.append("/folder2/") path_to_watch.append("/folder3/") before =[ for i in range(len(path_to_watch))] for item, folder in enumerate(path_to_watch): before[item].append([f for f in os.listdir (folder)]) print before while 1: time.sleep (3) for item, folder in enumerate(path_to_watch): after = [f for f in os.listdir (folder)] added = [f for f in after if not f in before[item]] removed = [f for f in before[item] if not f in after] if added: print "Images Added: ", ", ".join (added) if removed: print "Images Removed: ", ", ".join (removed) before[item] = after