0

I would like to monitor the directory using python. Whenever there is a new file the program will notify the user.

Current I am using a loop, which run os.listdir, to poll the directory regularly. However this is very inefficient. Is there any way that I could setup some software trigger (in Python) to enhance the efficiency?

Thanks in advance

Winston
  • 85
  • 1
  • 7

1 Answers1

2

See http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html for Windows and http://sourceforge.net/projects/python-fam/ for Linux. Also, you can check out https://github.com/gorakhargosh/watchdog/, which is multi-platform.

kirbyfan64sos
  • 10,377
  • 6
  • 54
  • 75