Question: I want to copy the latest file from a Folder(and subfolders) to a new location.
The following code works well, BUT I do not want to filter by Date AND Time (/O:D), but DATE only, so that all files from the same date will be copied to the new location as the latest files.

```
FOR /F "delims=|" %%I IN ('DIR "D:\Backups\DB\*.bak" /B /O:D /S') DO SET NewestFile=%%I
copy "%NewestFile%" "D:\Latest"

```

Answer: 
You can use xcopy `/D` to accomplish what you want :

```
 /D:mm-dd-yyyy
                Copy files changed on or after the specified date.
                If no date is given, copy only files whose
                source date/time is newer than the destination time.

```
```
@echo off
set source="E:\backups\daily\database1"
set target="E:\backups\daily\newdb.bak"

FOR /F "delims=" %%I IN ('DIR %source%\*.bak /A:-D /O:-D /B') DO COPY %source%\"%%I" %target% & echo %%I & GOTO :END
:END
REM this copy a newest file at E:\backups\daily\database1 folder 
REM to other folder E:\backups\daily\ and the file name changed to newdb.bak

```