I'm processing images put into specific folder.

For that I run script with launchd.plist put into ~/Library/LaunchAgents
Everything work smoothly. But I want put resulting files into subfolder of that folder.
Folder is not empty, it has subfolder, so my script is run over and over again every 10 seconds.
There is nothing to process. But launchd runs script ten times a minute wasting resources. How can I hide from launchd subfolders in folders from QueueDirectories parameter?
Filenames are arbitrary so I can't use WatchPaths parameter.
I believe parameter like maxdepth should exist.

Any solution?

  • Adding the launchd.plist to the question and using real names for the folders in the text would help to understand your problem. And: Is there a specific reason why the target folders must be inside the folder?
    – nohillside
    Commented Sep 21, 2012 at 14:06
  • 1
    @Patrix, real names really don't matter. Everything work as supposed. I only want find a way to run script if there are any files on first level of my queued directory, not in subdirectories. Many Apple's examples of FolderActions with AppleScripts put results into subfolders, and I find this convenient. I drag files into folder, wait a minute and see results in Processed subfolder. What may be easier for user? Commented Sep 21, 2012 at 14:15
  • Using real names and code makes it easier for us to understand your problem.
    – nohillside
    Commented Sep 21, 2012 at 14:45
  • QueueDirectories parameter of launchd.plist file runs script when this folder is empty. Do you know the way how make launchd ignore subdirectories of QueueDirectories? Commented Sep 21, 2012 at 15:12

1 Answer 1


QueueDirectories won't work anyway, because it'd trigger on the subdirectories themselves whether or not they had any files in them. The mere existence of subdirectories in the watched directories will trigger the script.

Instead, you should use WatchPaths on the main directory itself -- whenever a new image file is added to the directory, the directory is modified, so WatchPaths will trigger your script to process the file. Moving the image file will modify the directory again, but since it happens while your script is running it won't trigger a rerun.

  • I am stupid. When you gave reply, it became obvious. Everything works just fine now. And should add, that script is triggered only once. Changes to the watched folder made when process is already running do not trigger process again, doesn't matter changes made by running process itself or by other processes. Last is not a problem. To process later added files script has to issue find command again and again until list of files is empty. Thanks a lot for your help! Commented Sep 21, 2012 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .