I have the input path as C:\Student\Temp in the Temp folder, there will be many other folders. I want to get the latest folder name order by descending.
-
What do you mean by latest folder name - latest folder by creation or by usage ?royki– royki2015-07-23 17:33:02 +00:00Commented Jul 23, 2015 at 17:33
-
by folder name, all folders names are with name as " created time"PRK– PRK2015-07-23 17:36:31 +00:00Commented Jul 23, 2015 at 17:36
Add a comment
|
1 Answer
@echo off
for /f "tokens=* delims=" %%# in ('dir /b /a:d /o:d /t:c "C:\Student\Temp"') do set "latest=%%~nx#"
3 Comments
Little Santi
You should add the extension format (
set "latest=%%~nx#"), for the case that some folder has no name and only extension.PRK
How to print the folder name from the result, to verify the batch is working
npocmaka
@Gani
echo %latest%