I have a Windows directory which contains 4 files in total. The file names are as follows:
- Address_1502.csv
- Address_1602.csv
- Site_1502.csv
- Site_1602.csv
The prefix of the file name never changes so the files will always begin with Address_
or site_
. I am trying to find a command which can copy the most recent of the two files from their current directory in to a different directory. I currently have the following script however this only finds the newest of all 4 files and copies it over however I would like to find the newest of the two Address_ files AND the newest of the two Site_ files.
Can anyone help at all?
set "source=D:\TEMP_ONLY\SOURCE"
set "dest=D:\TEMP_ONLY\DESTINATION"
pushd "%source%" ||(
echo.Source does not exist&pause&goto EOF)
for /f "tokens=*" %%f in (
'dir /A-D /OD /B') Do set "file=%%f"
popd
xcopy /d /i "%source%\%file%" "%dest%\"