Copy newest file from folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mygaikwad
Posts: 1
Joined: 15 Mar 2013 04:59

Copy newest file from folder

#1 Post by mygaikwad » 15 Mar 2013 05:11

I want code in batch programming
i have thousands of file ilke
MARTY 12-03-2012
BATCY 15-01-2013
JYTCHE 10-12-2011

this type of file i have so i want to find newest date file and save on destination folder

in above list newest file BATCY 15-01-2013
so copy this file to destination folder

i want this code in batch programming

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Copy newest file from folder

#2 Post by foxidrive » 15 Mar 2013 05:21

This checks the files date stamp.

Code: Select all

@echo off
for /f "delims="  %%a in (' dir /b /a-d /od ') do set "file=%%a"
copy /b "%file%" "c:\destination"

Post Reply