Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  patrix Sep 21 '12 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? –  Valeriy Van Sep 21 '12 at 14:15
    
Using real names and code makes it easier for us to understand your problem. –  patrix Sep 21 '12 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? –  Valeriy Van Sep 21 '12 at 15:12
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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! –  Valeriy Van Sep 21 '12 at 22:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.