How can I monitor a directory, and send an email whenever a new file is created?
I currently have a script running daily which uses find to search for all files in a directory with a last modified date newer than an empty timestamp file:
#!/bin/bash
folderToWatch="/Path/to/files"
files=files.$$
find $folderToWatch/* -newer timestamp -print > $files
if [ -s "$files" ]
then
# SEND THE EMAIL
touch timestamp
Unfortunately, this also sends emails when files are modified. I know creation date is not stored in Unix, but this information is available in Finder, so can I somehow modify my script to use that information date rather than last modified?