Code: Select all
@echo off
setlocal
pushd \\server1.com\developer\inetpub\Ftproot\XMLs
echo.
for /f "tokens=2 delims=_" %%a in ('dir /b /o-d ABC*.xml') do (
for /f %%b in ('dir /b /o-d ABC*%%a*.xml') do (echo %%~b - %%~tb &&goto:out)
)
:out
popd
This just finds the latest ABC xml file in the directory. Now I need to find the 2nd latest and list all of the files between the 2nd latest ABC xmls and all of the files after the latest ABC xml file.
I can't really do a dir listing for this as even a small subset would be hundreds of files. Here is a very small subset of what I expect to return.
Code: Select all
08/20/2015 05:50 PM 8,829 BC6009490001_ACCTV21_20150820_CHG_367_107431247A.xml
08/20/2015 05:50 PM 11,552 BC6009490001_BALMIS_20150820_CHG_367_107432647B.xml
08/20/2015 05:49 PM 679 ABC_20150820_107481745D.xml
08/20/2015 05:48 PM 7,647 ID1779750001_BALMIS_20150820_NAC_5_1074336956.xml
08/20/2015 05:48 PM 7,650 ID1779740001_BALMIS_20150820_NAC_5_107447244U.xml
08/20/2015 05:48 PM 7,604 ID1778730001_BALMIS_20150820_NAC_5_107434944I.xml
08/20/2015 05:48 PM 7,786 ID1808430001_BALMIS_20150820_NAC_2_1074206446.xml
08/20/2015 05:43 PM 8,911 SB1522960001_ACCTV21_20150820_EXT_3_107249691J.xml
08/20/2015 05:43 PM 6,141 SB1522960001_BALMIS_20150820_EXT_3_107400191K.xml
08/20/2015 05:43 PM 623 ABC_20150820_1074331234.xml
So, I can find the latest ABC*.xml file easily but I want to get the 5:43 one and everything above it. The search date has to be extracted from the file name because sometimes it differs from the date dir returns.