Questions

Copy newest file

Tags:
+
0 Votes
Locked

Copy newest file

cmm8907
I need a bat file that will copy only the newest file in a directory. I currently have this:
FOR /F "delims=" %%I IN ('DIR C:\source*.* /B /O:-D') DO COPY "%%~fI" "C:\destination"

This will sort all files in the directory and then copy them all in order of modified or created date starting with the newest one.

Basically I need it to stop after it copies that first file.

Any suggestions?