Solved need to take latest file from windows batch script

Hewlett-packard /
February 25, 2013 at 02:32:09
Specs: Windows 7, 4GHZ
i have file names like xxx_20130210,xxx_20130212, and xxx_20130220 etcc,
than i have to take only latest file and process it.
how to do it from windows batch script

See More: need to take latest file from windows batch script

Report •


#1
February 25, 2013 at 02:46:55
✔ Best Answer
@echo off
for /F "delims=" %%i in ('dir /B /A-D "Your_Folder" ^| sort /+5') do set file=%%i
echo.%file%

Replace /+5 with /+12 to apply to the same question you posted and then vanished related to slightly different filenames.

Report •

#2
February 25, 2013 at 19:49:09
IVO is right, of course.

You can use this to get the latest, regardless of names.

@
for /F "delims=" %%a in ('dir /B /A-D /o-d') do (
echo.%%a
goto :done
)
:done

=====================
M2 Golden-Triangle


Report •

Related Solutions


Ask Question