Launchd WatchPath Arguments?
I wish to create a small script that takes a file in a directory, gets its metadata (with 'mdls') and appends this to the end of a text file.
This is not a problem when 'batch' processing the contents of an entire directory. However, I wish to set the dir as a launchd 'watchpath' and have it call the script whenever a file is added. This has created several problems for which I cannot see a solution...
1) How can I identify which files have been added to the directory and pass these as arguments to the script? If that is not possible, can I identify them by some other methd?
2) As the script would be executed on ANY modification of the directory, how can I distinguish between the addition of files and the removal of files. As this is a log of all files that have passed through the dir, I don't wish to overwrite the txt file when something is removed.
Should I forget using launchd and use folder actions? Off the top of my head, I think an applescript would do the trick.
Cheers for any help
G4 450 Sawtooth Mac OS X (10.4) 720Mb ram
G4 450 Sawtooth, Mac OS X (10.4), 640Mb ram