newest folder name

  • Thread starter Thread starter Kok Yong Lee
  • Start date Start date
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.
 
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
 
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 - - - - - - - - - -
 
Back
Top