File Watch Dependency Examples

The File Watch Dependency is a very useful feature in SmartBatch.  It is often easier to learn by example and since there are many filter options available, these examples will help you configure your File Watch Dependencies.

Example 1:  Run an Operation any time a file is created in a folder

 

Notice that the Folder, File Name and Change type have been set.  The File Name is particularly interesting since it contains a wild card (meta characters) indicating that any file with any extension that is created in the folder should cause the Operation named DataLoad to run.

Note:  It’s important to note that the File Watch Dependency event is not reset until after the Operation completes.  In other words, the Operation DataLoad will only be run once at any point in time.  So if another file is created in the folder while DataLoad is running an event will not occur.

Depending on how the file is created, you may want to try the following configuration to generate an event when the file is created:

Example 2:  Run an Operation any time a file with the .dat extension is created in a folder

 

When using File Explorer or when programmatically creating a file you need to be aware of when the File Watch Dependency file created event will occur.  The created event is fired when the file handle is created.  If you are testing with File Explorer, create the file in another folder.  After the file is created cut and paste the file into the Folder identified in the File Watch Dependency.  If you use File Explorer and directly create a file using the right-click New option, the create event will not occur in this case since the created file does not match the filter criteria.  For programmatic file creates be sure the to check the documentation of the programming language or API being used to determine when the file handle is created.  This may occur on the file open or perhaps when you first write to the file.

Example 3:  Run an Operation any time a change occurs on a specific file

 

Example 4:  Run an Operation when a change occurs on any file in the folder with the .dat extension

 

Example 5:  Run an Operation when any file is deleted from the folder

 

Example 6:  Run an Operation when any file is renamed in the folder