Hi,
I am trying to write a batch file to find the folder that has the largest number in its name.
i.e. I have 3 dummy folders with alphanumeric names in the directory
Prod110000
Prod112000
Prod114000
So it should find “Prod114000” for me. I’m trying to pull just the numbers part of the folder name so I can use GTR to compare – I am having troubles pulling the numbers part out of the batch variable (%%G) though because I can’t manipulate it.
I suspect there is also some problem in the “set latestdir=%%G” statement too.
What I (only) have right now is this:
g:
cd G:\xxxxxxxx
for /D %%G in (“Prod*”) do if %%G GTR %latestdir:~4,10% set latestdir=%%G
Thanks for the help!
Good luck.
@echo off cls setlocal cd /d G:\xxxxxxxx for /f "tokens=*" %%1 in ('dir /b /ad /on prod*') do ( set latestdir=%%1 ) echo Latest directory name=%latestdir% echo. echo Numbers in latest directory name=%latestdir:~4%Please come back & tell us if your problem is resolved.