If you have routine, file-based tasks that need to be automated, such as setting up an email alert to be sent every time a document is saved to a certain directory, the Watch Directory tool is something you might find to be very useful. I'll take you through one example that will illustrate how it works and explore some of the features that Watch Directory offers
I looked into Watch Directory so that I could automate an alert email to send when specific files were created. For example, if an application used in your environment creates a log file every time it executes and you wan to be notified when it happens, you can set up an alert that sends with an attachment of the log file.
Creating tasks to watch
Let's look at one simple example of sending an alert email when a file is created. To configure a task to handle this, complete the following steps.
1. Open the Watch Directory Control Center (and accept the UAC prompt if enabled).
2. Click the New Task toolbar item or select the File Menu and choose New.Note: There will be one task in Watch Directory by default for sending email. This task is configured to run as part of the application by default. If you select the View menu and then choose Email you can configure the postman task to run as a service. This will remove the need to start it every time you start Watch Directory. Simply select Automatically Start/Stop the postman service. 3. When the plugins window appears, shown in Figure A, you can choose the type of action you wish to create.
For this example, I'm going to choose Send An Email from the All Plugins list (or from the Notification tab). Click next.4. Create your Email settings for this task by entering the recipient's email address, subject, and body information. Figure B shows the Email Settings dialog.
Email task notification settingsNote: If you haven't gotten your general mail settings configured when you click next, you will get a pop up letting you know that these aren't configured; however, Watch Directory will let you continue to create the task.
5. On the Send An Email task configuration panel, you configure the following settings:
- Send An Email To: Enter the email addresses of your recipients, keeping the TO: and CC: respectively.
- From Address: Enter an email address here if this task should have a different sender than the default.
- Use This Subject : This is filled in with variables by default, but can be edited to have a static subject .
- Enter The Message Body: Fill in the body of the message here.
If you want to have the changed file attached to the email generated by a task, check the attach the file box. Popularly used variables are listed at the right of the dialog box. When the email settings are complete, click next to continue.
6. On this screen, you specify a directory to watch. Perhaps C:\Reports could be specified here so that any files dropped in that directory get emailed as soon as they are completed. The application will monitor subdirectories of your specified path if the Monitor Sub directories box is checked. You can also specify the number of re-tries for directories that are not available. When the path to watch is configured, click next to continue.
7. Next, you can add folders to exclude from monitoring. Enter or browse for the directory to exclude and click Add to get it on the exclusions list. Click next to continue.
8. Next, set criteria for monitoring within the directory. Suppose you want to include c:\reports and send out the reports or documents kept there, but any temporary files (*.tmp) should be excluded. Add *.tmp to the exclusions list here and these types of files will be skipped. Click next to continue.
9. The next screen allows you to specify a monitoring method. I usually keep the default option here because most new drives work well with this option. Click next after choosing a monitoring method.10. Now, you can specify which types of actions on files will trigger your email event; for example, only fire an email when new files are created. The default setting here is to have all events checked. Since reports are usually only sent when created, I changed the configuration to include only the first option, shown below in Figure C.
Sending will occur only on new files.
11. Clicking next after selecting actions to trigger an event will allow you to select when the task starts. You can use the following startup types:
- Immediately : Starts the task within Watch Directory immediately
- Delay Starting Task: Set an amount of time to delay the task
- Only Run On These Days: Runs the task on the selected schedule
You can also specify that multiple events against the same file should be merged before the email is sent out. Click next to continue.
12. Here, you will configure how long to wait for a file that is busy or not available; for this example, I have kept the default settings. Click next to continue
13. Next, you will provide a short name and description for your task. If you are using the professional version, this will be included in the name of your Windows Service if you choose to run the task that way (specified on the next screen). After entering a name for the task, click Next.
14. Here you will specify how you wish the task to run, by choosing from the following options:
- I will start the task manually (by pressing F5 or the Play button)
- From the startup menu of the current user
- From the startup menu for All users
- Run as a windows service (Professional edition only)
- Hide the run Window - allows output to be hidden
- Keep the task running when user logs off (pro only)
- Delay on startup - specify a number of seconds to delay task triggering on startup
15. Once you have chosen a startup option, click Finish to close the wizard and create your task. When the wizard closes you will be asked if you want to start the task now, click yes to start the task.All of the tasks you create can be edited by double clicking them within the Watch Directory Control Center. The options available when editing are arranged in a tabbed format shown below in Figure D.
Editing a previously created task
Configuring default email settings
To get the email task that was created above to work, we need to configure the general mail settings so that Watch Directory can find and log in to your email server to send mail.Double clicking the default mail task from the main window will bring up the settings box shown in Figure E.
General email settings
From here you complete your mails' server information and supply logon credentials. You can also specify a default sender. These are the only settings that need to be configured; the remaining settings can be left at their default. Once completed, click OK and start the System Mail task to begin sending mail for tasks with that plugin configured.
This application comes with many options for watching and acting on directories. Some of the plugins used are:
- Run multiple sub tasks *
- Automatically copy files
- Automatically sort files
- Automatically email when files are created/deleted
- Monitor the size of folders
- Automatically rename files
- Automatically delete files
- Automatically upload files via FTP
- Create thumbnails for photos
- Auto-generate HTML
- Auto-generate reports for auditing files
- Auto-start any application
- Auto-start batch files
- Compress and decompress zip files automatically
- Play sounds (wav) when new files are created
*- denotes Professional version onlyCost
There are two editions of watch directory, standard and professional. The standard edition costs $69 and the professional version costs $129.Feature comparison
The table below compares the features of Watch Directory Standard and Professional.
|Tasks that can run simultaneously||
Three (3) tasks can run at the same time.
|Can use multiple sub tasks plugin||
|Network directory monitoring||
No - only local drives supported
|Can use file age as criteria||
|Send email when problem found||
|Supports wdNotify to watch file system activity||
The application also comes with a 30-day free trial and all plugins are free for the application.
Derek Schauland has been tinkering with Windows systems since 1997. He has supported Windows NT 4, worked phone support for an ISP, and is currently the IT Manager for a manufacturing company in Wisconsin.