Solved

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

Posted on 2004-07-30
2
1,400 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
  • 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 125 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Rename files on Windows 10 49
How do I delete 2 44
Need to overwrite data when copy job is run 4 54
how to count files? 4 48
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…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

680 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