watchDirectory Help > Plugins > Run Multiple Tasks (Pro)
Take care when deleting files
If you configure a SubTask to delete, move or rename the detected file, subsequent SubTasks may fail.Tip: Use the output-file of one SubTask as input for another SubTask
While you can not directly use the output of one SubTask as the input for another SubTask, here is a little trick that may help.
Suppose SubTask-1 ZIPs files, and you want SubTask-2 to email that ZIP to someone.
Configure SubTask-1 (the ZIP task) and set its Mask to "*.zip", also click the option so masks have reversed meaning. The effect will be that SubTask-1 will run for all files except ZIPs.
Configure SubTask-2 (the email task) and set its mask to "*.zip". Do not select the "reversed meaning" option.
Run Multiple Tasks for Detected Files
This Plugin is only available in the Professional edition of watchDirectory.This plugin runs multiple "SubTasks" for detected new and changed files. All SubTasks will be called for the same detected file.
Some benefits of this plugin, compared to running separate tasks, are:
- Less tasks to run.
A SubTask consumes less resources (CPU, memory...) than a "real" task. - Less disk access.
All SubTasks share the same file-detection of their main task. - Guaranteed order of execution.
If you have multiple tasks monitoring the same directory, you can not be sure which one will detect a new file first. SubTasks will always run in the configured order. - Better Overview, easier maintanance.
Ten tasks, each having ten SubTasks (10*10=100 SubTasks), are a lot easier to manage than 100 "real" tasks. - Overcome Operating System limitations.
Windows™ has limits to the number of Services it can run. By combining several tasks, you prevent hitting that limit.
There are a few limitations:
- All SubTasks run for the DETECTED file.
Currently, you can not easily use the "output file" of one SubTask as input for another SubTask. However, there is a work-around that may help - see the Tip side-box. - Not all Plugins are supported as SubTasks.
See the "Supported Plugins" sidebar for the list of supported plugins. Also see the Plugin Notes at the bottom of this page for some potential problems. - One Monitored Directory.
All SubTasks share the same file-detection engine and settings. - Can only react upon new and changed files.
For example, this plugin does not support events for renamed and deleted files.
How to run the SubTasks
There are 3 ways you can run the SubTasks:
- Run Only 1 SubTask - the First one that Matches
Each SubTask has 1 or more file-masks (*.doc). If you select this run-mode, at most 1 SubTask will handle the detected file.
Note that for this run-mode, the order of SubTasks is important. - Run All SubTasks - Stop on Failure
All SubTasks having a matching file-mask will run for the detected file. When a SubTask fails, other SubTasks will not run. - Run All SubTasks - Continue on Failure
All SubTasks having a matching file-mask will run for the detected file. When a SubTask fails, other SubTasks will run.
Create a new SubTask
You can create a new SubTask in the following ways:
- By Copying the settings of another Task.
- Select the Task to copy from the "Create new SubTask based on" drop-down
- Enter a unique SubTask name
- Press the button labeled "Add"
- By Copying another SubTask.
- Select the SubTask to copy
- Enter a unique SubTask name
- Press the button labeled "Copy"
- By "Starting Fresh".
- Select the Plugin to use from the "Create new SubTask based on" drop-down. Their descriptions are displayed in bold.
- Enter a unique SubTask name
- Press the button labeled "Add"
- Make sure to properly configure the new SubTask
After you created the new SubTask, the SubTask Settings window will automatically open. If you used method 3 to create the new SubTask, please make sure to properly configure the Plugin as its settings are now "empty". The other 2 methods will have copied the original plugin settings.
Plugin Notes
A few notes about the supported Plugins.
Automatically Copy Files
If you use this Plugin as a SubTask, and you select the option "remove the file after successful copy", other SubTasks that
run after this one will most likely fail as the detected file does not exist anymore. If this is the last SubTask this option
causes no problems.
Automatically Delete Files
This Plugin is typically used as the last SubTask. If another SubTask is configured after this, it may fail as the detected file is deleted.
Send Email for Detected Files
Please note that this Plugin only prepares the email to be sent. The real email is sent a bit later by the wdPostman (System.Mail) task.
If you configure the email SubTask to attach the detected file and another SubTask is configured to remove the file, even if that SubTask runs after
the email SubTask, the detected file may already be removed when the email is sent.
Advise: configure the email SubTask to run as the last SubTask and let the email SubTask remove the file.
Automatically Upload Files
If you select the option Delete the file or Move the file to... for this SubTask, the SubTasks that follow may fail as the detected file is not present anymore.
Rename Files
If you use this plugin, it should typically be configured as the last SubTask. If another SubTask is configured after this, it may fail as the detected file is renamed.
Unzip Files
If you use this Plugin as a SubTask, and you select the option "Delete ZIP file after uncompressing", other SubTasks that run after this one will most likely fail as the detected ZIP file does not exist anymore. If this is the last SubTask this option causes no problems.