аватар question@mail.ru · 01.01.1970 03:00

How to track file changes and copy changed files to another folder?

The essence of the program: check the files for the last change, and if they were changed, then we copy them to another folder.

So the problem is that I have a list of files obtained using the os.listdir (PATH) . But its contents, just text.

How can I tie the elements to real files?


ps from:

date of the previous change, preserved in the list/dictionary. I want to make sure that every 30 seconds it was checked whether the file has changed.

аватар answer@mail.ru · 01.01.1970 03:00

To complete the picture, there is not enough answer with

   import  logging  import  Inotify.adapteS_default_log_format =  ' %(asctime) s - %(name) s - %(LEVELNAME) S - %(Message) S'  _LOGGGER = logging.getlogger (__ name __)   def   _ configure_loging  ():  _logger.setlevel (logging.debug)  ch = Loging.streamHandler ()  Formatter = logging.formatter (_default_log_format)  ch.setformatter (Formatter)  _logger.addhandler (ch)   def   _ main  ():  i = inotify.adapters.inotify ()  i.add_watch ( ''/tmp ')   try :   for  event  in  i.event_gen ():   if  event  is   not   none :  (Header, Type_names, Watch_path, Filename) = Event _LOGGER.info ( "" WD = (%D) MASK = (%D) cookies = (%D) LEN = (%D) MASK- & GT; Names =%S ""    "Watch-Path = [%S] Filename = [%S]" "" , ,  Header.wd, Header.mask, Header.cookie, Header.  Len , Type_Names,  Watch_Path)   finally :  I.remove_watch ( ''/tmp ')   if  __name__ == ' '__ main __' :  _configure_logging ()    . _main ()     

I.Event_GEN () yILD-VILD Events about changing files in the catalog.

Latest

Similar