Windows Batch Scripting: Newest File Matching a Pattern

Posted by Eddie Parker on Super User See other posts from Super User or by Eddie Parker
Published on 2010-03-23T23:00:46Z Indexed on 2010/03/23 23:03 UTC
Read the original article Hit count: 476

Filed under:
|
|
|

This would be lightning quick in linux, but I'm not familiar enough with windows flavour of batch scripting.

Basically I want to look for a series of files matching a certain wildcard, and get the one with the most recent modified date.

I've gotten as far as:

for %%X in (*.exe) do (
REM Do stuff....
)

But I'm not sure what manner of comparison operators there are, or if there's a better way of doing this.

Anyone offer up any good solutions? Ideally it would involve a vanilla install of Vista; so no special trickery like cygwin/etc.

© Super User or respective owner

Related posts about Vista

Related posts about batch