I have a batch file which calls a Perl file which requires a input as a text file
CreateTasks.bat:
Createtask.pl -f %1
where %1 - "C:\task\TASK1234.txt"
The file TASKxxx.txt (ex : TASK1234.txt) will be create from another application and at any point the folder C:\task\’ can contain one more more Tasxxx.txt files
I want to Call the CreateTasks.bat once for each file, reason is that This folder will be filled in with the text file and this folder needs to be monitored.
How can I call achieve this?
I was thinking of scheduling a Batch file which runs every 5 mins. Get always the first file and call this batch file
is this good approach?
if something is not clear please do let me know and I will try to clarify
Thanks
Karthik
You may use a BAT file that periodically loops over all the files of a given extension in a given folder, and for each such file found, it would invoke some special process and, if succesful, rename the file so it does not process it again. This simple code implements the main idea of this strategy, use it to get you started.
But, watch carefully, as there are many traps in this road; to cite some, take care with the error processing, address possible issues with cancellation of processes, stalled executions, double or multiple executions, even in parallel, and consider race conditions in all the checks you might prepare.