Scanning directories for new files?

GrayShark howe.steven at gmail.com
Tue Dec 21 15:03:20 EST 2010


On Tue, 21 Dec 2010 14:17:40 -0500, Matty Sarro wrote:

> Hey everyone.
> I'm in the midst of writing a parser to clean up incoming files, remove
> extra data that isn't needed, normalize some values, etc. The base files
> will be uploaded via FTP.
> How does one go about scanning a directory for new files? For now we're
> looking to run it as a cron job but eventually would like to move away
> from that into making it a service running in the background.

You can try pyinotify.
Pyinotify is a Python module for monitoring filesystems changes. Pyinotify 
relies on a Linux Kernel feature (merged in kernel 2.6.13) called inotify. 
inotify is an event-driven notifier, its notifications are exported from 
kernel space to user space through three system calls. pyinotify binds 
these system calls and provides an implementation on top of them offering 
a generic and abstract way to manipulate those functionalities.

I'm assuming your using Linux. You seem to be at least using UNIX (cron).

read more at: http://pyinotify.sourceforge.net/

Steven



More information about the Python-list mailing list