I tested this program, it checks a directory if a file is deleted, renamed or modified. I wonder how can I check a direcory by exluding certain files ? How can I modify the variable
PATH_TO_WATCH = ["C:/myDirectory"]
so that the program probes C:/myDirectory
but excludes 2 files from checking (file1.txt and file2.txt) ?
The following code must be replace.
for action, file in results:
full_filename = os.path.join (path_to_watch, file)
if not os.path.exists (full_filename):
file_type = "<deleted>"
elif os.path.isdir (full_filename):
file_type = 'folder'
else:
file_type = 'file'
yield (file_type, full_filename, ACTIONS.get (action, "Unknown"))
By this code:
for action, file in results:
if (file != 'file1.txt' and file != 'file2.txt'): #here you cut the check of the files you don't want.
full_filename = os.path.join (path_to_watch, file)
if not os.path.exists (full_filename):
file_type = "<deleted>"
elif os.path.isdir (full_filename):
file_type = 'folder'
else:
file_type = 'file'
yield (file_type, full_filename, ACTIONS.get (action, "Unknown"))