It is convenient to use Python to monitor file system changes under Windows. The example code is as follows, very simple, not much to say.
Import Osimport Win32fileimport win32conactions = {1: "Created", 2: "Deleted", 3: "Updated", 4: "Renamed from som Ething ", 5:" Renamed to something "}file_list_directory = Win32con. Generic_read | Win32con. Generic_writepath_to_watch = "." Hdir = Win32file. CreateFile (Path_to_watch, File_list_directory, Win32con. File_share_read | Win32con. File_share_write, None, Win32con. Open_existing, Win32con. File_flag_backup_semantics, None) if __name__ = = ' __main__ ': Print ("123") while 1:print ("321") result s = win32file. READDIRECTORYCHANGESW (Hdir, #handle: Handle to the directory of Be Monito Red. This directory must is opened with the File_list_directory access right. 1024x768, #size: Size of the buffer to allocate for the results. True, #bWatchSubtree: Specifies whether the READDIRECTORYCHANGESW function would monitor the directOry or the directory tree. Win32con. File_notify_change_file_name | Win32con. File_notify_change_dir_name | Win32con. File_notify_change_attributes | Win32con. File_notify_change_size | Win32con. File_notify_change_last_write | Win32con. File_notify_change_security, None, None) for the action, file in results:full_filename = Os.path.join (path_to_watch, file) pr Int (Full_filename, actions.get (Action, "Unknown"))
Related Reference Links:
Http://docs.activestate.com/activepython/2.4/pywin32/win32file__ReadDirectoryChangesW_meth.html
Http://docs.activestate.com/activepython/2.5/pywin32/win32file__CreateFile_meth.html
Python monitors file changes under Windows