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:
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.
On the Runtime tab, click the Output Monitors ellipsis button (...).
Click "Add a New Output Monitor" then set the options as shown:
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: