Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'watching folders' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
watching folders
Authored by: hayne on Oct 01, '03 06:51:52PM
When I wrote the script, I hadn't considered using it to watch folders but I see that this can be useful too - e.g. pwharff's comment indicates that he is using it to monitor a folder for files added.

To make the script work better when used to watch folders, I would recommend changing the line that does the 'ls -l' to use 'ls -ld' instead. I.e. change it to:
system("/bin/ls -ld \"$filename\"") if $show_info;
This will make it just list the info about the folder itself instead of listing all the files in that folder (which gets rather noisy if the folder contents change much). It will still give you the info for a file as before, so it's a win-win scenario.

In case you wanted to do something different with folders that have changed as opposed to files that have changed, you could test if $filename is a folder by using if (-d $filename)

[ Reply to This | # ]