views:

50

answers:

1

I don't do windows batch programming, nor do I need to go that far down the rabbit hole.

I have directory structures as such:

dir1000000/file.txt
dir2000000_1/file.txt
dir2000000_2/file.txt

I need to select the file.txt from the path with the lexicographically greatest value, i.e. dir2000000_2/file.txt. How do I go about doing this?

+3  A: 

Assuming the file is always file.txt and only the directory is variable...

FOR /F "delims=" %%a IN ('DIR /ad/b/on') DO SET mydir=%%a
SET myfile=%mydir%\file.txt
BenV
+1 As an FYI, since the OP's comment indicates he might just be sorting by date, he could swap out the `DIR /ad/b/on` for `DIR /ad/b/od` if that's the case.
Dusty