Using Output Monitors

   

Here we use Output Monitors to solve the problem of finding the most recent file in a directory. In this example, we want to find the most recently changed file in the c:\builds\source directory. This DOS command lists the files in order from oldest to newest: dir /b /od /a-d c:\builds\source\*.*

 

The output is as follows:

 

LOGOSTRS.PAS

LOGOMAIN.PAS

ABOUT.PAS

hello.pas

BBXAbt.pas

bbxmain.pas

ttree.pas

logging.pas

servtest.pas

 

We thus simply want to retrieve the last line of that output. An Output Monitor do this.

 

First, create a variable to hold the name of the most recent file. Call it "filename".

 

Next, create a Run DOS Command / Batch File action.

 

tt_outputmonitor1

 

On the Runtime tab, click the Output Monitors ellipsis button (...).

 

Click "Add a New Output Monitor" then set the options as shown:

 

tt_outputmonitor2

 

The Search String defines what lines of text are selected. In this case, we don't care what the text is - we just want the last one. So the *, combined with Use Wildcards matches any text.

 

The Behaviour lets you choose options like failing if the text doesn't match. The Save Last Match to Variable option is obviously the appropriate one here.

 

Lastly, choose the Variable you created - Filename.

 

The final result looks like this:

 

tt_outputmonitor3