Name: dave19 Date: March 28, 2008 at 19:05:11 Pacific Subject: batch to check last modified file OS: WinXP SP2 CPU/Ram: 512
Comment:
Hi, I need a batch file to check last modified file in folder and copy it another specified place. is there any command to check last modified or new date out of files?
@echo off setlocal set srcDir=C:\Source set destdir=c:\dest set lastmod= pushd "%srcDir%" for /f "tokens=*" %%a in ('dir /b /od 2^>NUL') do set lastmod=%%a if "%lastmod%"=="" echo Could not locate files.&goto :eof copy "%lastLog%" "%destDir%"
for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d') do ( copy %%a d:\mystuff & goto :eof)
The directory is listed in reverse chronological order (most recent first) and as soon as the first (i.e. most recent) file is copied, the loop exits using goto.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE