how to use date command in batch file

January 30, 2011 at 01:43:59
Specs: Windows XP

@echo off

for /f "tokens=* delims= " %%a in ('dir /b/s D:\sba81\siebsrvr\log\*.log') do (
find "Error " < %%a >> Error.txt
for /f "tokens=* delims= " %%a in ('dir /b/s *.txt') do (
FINDSTR "2010-01-27 2010-01-26" "Error.txt"< %%a >> Error.log

first for loop in the batch file searches for all "error" keywords in all log files and in second loop i am using two dates as highlated in bold to filter the all errors to get only yesterday and today occured errors. For this i need to change the dates daily.

Can any one give me the solution how to include date command in the above batch file to search for yesterday's and today's errors?


See More: how to use date command in batch file

Report •

January 31, 2011 at 06:59:09
Many people ask for date math for batch scripts. We keep giving them the same answer: The command prompt sucks at date math. Pick a language that supports date math, even if it just does your math, and returns.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question