Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello-
I have a directory that gets updated each day with new directories with sequential names:myfolder_1
myfolder_2
myfolder_3
...etcI need to get the name of the folder with the greatest number at the end, so in this sample I would want to get myfolder_3.
There may be other folders in there with different names, but I know that I want "myFolder_*" with * being the greatest number.
Any tips on how to pull this off? Thanks!
Mac

The XP Forum may be a better choice, NT based O/S does not have pure MS-DOS, it has:
CMD.EXE = NT Command PromptCOMMAND.COM = NT Virtual Dos Machine (loosley based on an emulation of MS-DOS 5/6/7/8)

As per #1 DOS and NT are quite different.
In 2K/XP:
If the creation is strictly as you describe, try this:
::== nrefoldr.bat
@echo offfor /f %%D in ('dir /b/ad/od myFolder_*') do set newest=%%D
echo %newest%
:: DONENote that if the numbers were limited to 1 thru 9, you could just as well sort by name [/on]. But if 10 shows up it breaks down because, in a SORT, 10 comes before 9.
That can be gotten around, but takes some doing.
All if this is for 2K/XP CMD.exe
If at first you don't succeed, you're about average.M2Go

![]() |
reformtting c: on 486
|
booting os on 286 (follow...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |