Skip to content

Instantly share code, notes, and snippets.

@itayd
Created November 23, 2010 15:33
Show Gist options
  • Save itayd/711941 to your computer and use it in GitHub Desktop.
Save itayd/711941 to your computer and use it in GitHub Desktop.
scans current directory, when a file's mtime is change, execute command in args concatinated to filename
#!/usr/bin/python
import os
import time
latest = {}
while True:
fs = os.listdir('.')
for f in fs:
s = os.lstat(f)
changed = True
if f in latest.keys():
changed = s[8] != latest[f]
latest[f] = s[8]
if changed:
print f
time.sleep(1)
@itayd
Copy link
Author

itayd commented Nov 23, 2010

  • does shallow scan
  • does not take into account deleted files
  • checks only mtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment