HiTek Software Home
 
Run task if file exists in a directory, else send an email
Date Updated  -  07/22/2007
Description
I have a need to send an email, if a file does not exist in a directory. If the file does exist, I need a macro to run.
Solution

1) Create a File Monitor using the following settings:
Dir = dir_name
File = filename
Select option = Run task if file exists
Task to Run = Your_Macro_task

2) Create a Chain Task with the following settings:
Step 1 = File Monitor task
Options = If Exit Code = -100, Go to step 100
Step 2 = Your_Email_Task

Schedule this Chain task. If the file exists in the folder, then the File Monitor task will run the Macro Task. In this case, the File Monitor task returns with an exit code = -100. Hence, in the Chain task will exit (i.e. go to step 100) without sending the email.
If the file does not exist in the folder, then the File Monitor task will not run the Macro Task, and it will return with an exit code = 0. In this case, step 2 of your chain will run, i.e. the Email task