Copy newest file - TechRepublic
Question
December 8, 2011 at 06:57 AM
cmm8907

Copy newest file

by cmm8907 . Updated 14 years, 6 months ago

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?

This discussion is locked

All Comments