newest folder name

K

Kok Yong Lee

Hi there,

how do I design a cmd command to retrieve the newest created folder names?

I know that dir /b /o:-d will returnall the folder from newest to oldest,
but the question is how do I extract the first value?

thanks.
 
F

foxidrive

Hi there,

how do I design a cmd command to retrieve the newest created folder names?

I know that dir /b /o:-d will returnall the folder from newest to oldest,
but the question is how do I extract the first value?

thanks.

Extract the last name - untested:

@echo off
for /f "delims=" %%a in ('dir /b /a:d /o:d') do set var=%%a
 
P

Phil Robyn [MVP]

foxidrive said:
Extract the last name - untested:

@echo off
for /f "delims=" %%a in ('dir /b /a:d /o:d') do set var=%%a

If you absolutely have to read the first line rather than the last,
here's one way:

- - - - - - - - - - begin screen capture - - - - - - - - - -
<Win2000> D:\junkdir>dir /ad /o-d c:\temp | find "/"
10/27/05 10:29p <DIR> _ISTMP1.DIR
02/15/05 09:31p <DIR> Adobe
05/13/03 12:31p <DIR> Word8.0
05/13/03 12:31p <DIR> VBE
06/02/02 06:29a <DIR> nscomm40
01/16/02 10:17p <DIR> ..
01/16/02 10:17p <DIR> .

<Win2000> D:\junkdir>for /f "tokens=*" %a in ('dir /ad /o-d c:\temp ^| find "/"') do @echo %a>>zzz.txt&set /p fline=<zzz.txt

<Win2000> D:\junkdir>set fline
fline=10/27/05 10:29p <DIR> _ISTMP1.DIR
- - - - - - - - - - end screen capture - - - - - - - - - -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top