[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

compare file timestamp to current date/time and count new files added in last hour

Posted on 2004-07-30
2
Medium Priority
?
1,417 Views
Last Modified: 2008-03-06
I need a script that will compare the timestamp of the files in the folder c:\done to the current date and time and count any new files added.  The count and a description ( example : 5 new files processed for interface a) should be written to a text file that can then be emailed.  Thanks for your help in advance.
0
Comment
Question by:uhsdba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 11681259
Try this:

@echo off

setlocal

for /F "tokens=2-4 delims=/ " %%f in ('date /t') do (
 set mm=%%f
 set dd=%%g
 set yy=%%h
)

set yy=%yy:~-2%

set /A cnt=0

set curDate=%mm%/%dd%/%yy%

if exist log.txt del log.txt >NUL

for /F "delims=" %%a in ('dir /a-d /b %1') do call :PROCESS "%%a" %%~ta

echo Total new file(s): %cnt%
echo log.txt contains a list of the new files.

goto :EOF

:PROCESS

if %1==log.txt goto :EOF
if not "%2"=="%curDate%" goto :EOF

set /A cnt+=1

echo %~1 >>log.txt

The batch file accepts an option command line parameter that is the directory where you'd like to check. Example: newfiles c:\

Good Luck,
Steve
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 375 total points
ID: 11681270
You can suppress the output of the check file statement with this code:

if /I %cnt% GTR 0 echo log.txt contains a list of the new files.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question