Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

batch to check last modified file

Original Message
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?

Report Offensive Message For Removal


Response Number 1
Name: devil_himself
Date: March 28, 2008 at 20:19:34 Pacific
Subject: batch to check last modified file
Reply: (edit)
@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%"

Report Offensive Follow Up For Removal

Response Number 2
Name: dave19
Date: March 28, 2008 at 21:24:04 Pacific
Subject: batch to check last modified file
Reply: (edit)
Thanks! in the last line i believe its %logmod%

Report Offensive Follow Up For Removal

Response Number 3
Name: devil_himself
Date: March 28, 2008 at 23:42:13 Pacific
Subject: batch to check last modified file
Reply: (edit)
Yes ..

Report Offensive Follow Up For Removal

Response Number 4
Name: devil_himself
Date: March 28, 2008 at 23:42:58 Pacific
Subject: batch to check last modified file
Reply: (edit)
No ... Not %logmod% Its %lastmod%

Report Offensive Follow Up For Removal

Response Number 5
Name: dave19
Date: March 29, 2008 at 00:31:14 Pacific
Subject: batch to check last modified file
Reply: (edit)
Thanks, it works fine as it should..
how do ('dir /b /od 2^>NUL') works?

Report Offensive Follow Up For Removal


Response Number 6
Name: Mechanix2Go
Date: March 29, 2008 at 01:34:52 Pacific
Subject: batch to check last modified file
Reply: (edit)
more simply:

::=======
@echo off

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d') do (
copy %%a d:\mystuff & goto :eof)


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 7
Name: dave19
Date: March 29, 2008 at 05:31:41 Pacific
Subject: batch to check last modified file
Reply: (edit)
Thanks much M2, i got it clearly now :)

Report Offensive Follow Up For Removal

Response Number 8
Name: dave19
Date: March 29, 2008 at 06:53:47 Pacific
Subject: batch to check last modified file
Reply: (edit)
a little doubt, would %%a copy the first line?

Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: March 30, 2008 at 01:08:36 Pacific
Subject: batch to check last modified file
Reply: (edit)
not clear


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 10
Name: dave19
Date: March 30, 2008 at 02:35:02 Pacific
Subject: batch to check last modified file
Reply: (edit)
yeah after i tried to understand it.

Report Offensive Follow Up For Removal

Response Number 11
Name: klint
Date: March 30, 2008 at 13:55:11 Pacific
Subject: batch to check last modified file
Reply: (edit)
If you are asking about M2's code

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.


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: batch to check last modified file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


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

All content ©1996-2007 Computing.Net, LLC