Computing.Net > Forums > Disk Operating System > Finding directory with largest name

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Finding directory with largest name

Reply to Message Icon

Name: 99miles
Date: May 2, 2006 at 12:42:23 Pacific
OS: XP
CPU/Ram: intel
Product: ibm
Comment:

Hello-
I have a directory that gets updated each day with new directories with sequential names:

myfolder_1
myfolder_2
myfolder_3
...etc

I 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




Sponsored Link
Ads by Google

Response Number 1
Name: jessejames
Date: May 3, 2006 at 02:41:25 Pacific
Reply:

The XP Forum may be a better choice, NT based O/S does not have pure MS-DOS, it has:
CMD.EXE = NT Command Prompt

COMMAND.COM = NT Virtual Dos Machine (loosley based on an emulation of MS-DOS 5/6/7/8)



0

Response Number 2
Name: Mechanix2Go
Date: May 3, 2006 at 05:24:26 Pacific
Reply:

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 off

for /f %%D in ('dir /b/ad/od myFolder_*') do set newest=%%D
echo %newest%
:: DONE

Note 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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


reformtting c: on 486 booting os on 286 (follow...



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Finding directory with largest name

Create Directory with Variable Name www.computing.net/answers/dos/create-directory-with-variable-name/16276.html

DOS directory with today's date & time www.computing.net/answers/dos/dos-directory-with-todays-date-amp-time/10948.html

Creating Directories question www.computing.net/answers/dos/creating-directories-question/13252.html