|
|
Under some circumstances you may need TextPipe to run whenever a file appears in a folder or directory. This file could be generated by a third party program on the same computer, or by a third party program on a different computer (possibly running Unix). We need to repeatedly check to see if the files we need have appeared. This process is called polling. How often we poll determines how quickly the results will be available. For a near-real-time application we might poll every minute or every 30 seconds. For a batch job we might poll once an hour or every 6 hours. Or - see our new File and Folder Watcher tool An ExampleLet's say that the folder we are monitoring is E:\. The file we want to process will appear in this folder. E:\ can actually point to a Unix file system folder by using software like Samba or TotalNet Advanced Server to make Unix file systems available to Windows. We don't want to process the file until it is fully written. If the file is large it is quite possible we will see the file appear before its contents have been fully written. There are several options to avoid this: 1. Move Completed File to Monitored FolderHave the third party application first write its file to a hidden folder, then move the completed file to the monitored folder, E:\. A move operation always moves the entire file in one block, therefore there is no chance we will see a partial file. This solution is good if there is only one file to process. Here is the batch file we would use:
2. Using a Flag File or Semaphore FileHave the third party application write a file of known name (eg finished.txt) to indicate that it has finished. We can write a batch file that waits to see this file appear before it starts processing. This solution is good if there are multiple files to process. Here is the batch file we would use:
3. Multiple folders with different filtersIf you have multiple folders with different file types in each (each folder requiring a different TextPipe filter), try the following solution (which is just an extension of the batch file above):
|