0

I created one python script this will inform me if some files got changed in the directory and it is working, but i need to have an another message if a file got modified and is still open "modified but still in use" some thing like that.can any one please help

import os, time
path_to_watch = "C:\\Users\\u104810\\Desktop\\New folder"
before = dict ([(f, None) for f in os.listdir (path_to_watch)])
while 1:
  time.sleep (10)
  after = dict ([(f, None) for f in os.listdir (path_to_watch)])
  added = [f for f in after if not f in before]
  removed = [f for f in before if not f in after]
  if added: print ("Added: ", ", ".join (added))
  if removed: print ("Removed: ", ", ".join (removed))
  before = after
Manoj
  • 19
  • 4
  • Have you looked into https://stackoverflow.com/questions/11114492/check-if-a-file-is-not-open-not-used-by-other-process-in-python ??? – Fab Sep 09 '19 at 12:44
  • Possible duplicate of [Check if a file is not open( not used by other process) in Python](https://stackoverflow.com/questions/11114492/check-if-a-file-is-not-open-not-used-by-other-process-in-python) – FlyingTeller Sep 09 '19 at 13:07
  • yes i checked the answers of this question " if a file is not open( not used by other process) in Python" and this didn't answered my problem – Manoj Sep 09 '19 at 13:46
  • Manoj, if that is the case then further elaboration is needed as to why the mentioned answer does not apply to your specific problem. – Fab Sep 09 '19 at 14:22

0 Answers0