Date calculation using bat and txt file
Posted: 25 Dec 2009 03:58
Hi All,
Am fairly new to dos. Let me tell you what I want to achieve.
1. I got a bat file I ll call check.bat, when I run this it should compare the system current date with dates from a text file(dates.txt) and give me the required output.
2. Explanation using example.
I will run my check.bat file daily. And I also have dates.txt in my system. The content of dates.txt file will be like :
Username1/Password1/Fri 12/25/2009
Username2/Password2/Thu 12/24/2009
Username3/Password3/Wed 12/23/2009 etc.....
When I run this check.bat it should compare the current system date for eg: 12/25/2009 with every entry from this dates.txt file specified above. And should return a date which is 48 hrs before. So If I run today (12/25/2009) I should get dates which are equal and less than 12/23/2009).
3. I don't know how to do this: Currently my check.bat looks like this :
@echo off
setlocal
set value=
for /f "tokens=*" %%a in ('type C:\Demo\dates.txt 2^>NUL') do set value=%%a
echo value=%value%
@echo %value%
Thanks.
Am fairly new to dos. Let me tell you what I want to achieve.
1. I got a bat file I ll call check.bat, when I run this it should compare the system current date with dates from a text file(dates.txt) and give me the required output.
2. Explanation using example.
I will run my check.bat file daily. And I also have dates.txt in my system. The content of dates.txt file will be like :
Username1/Password1/Fri 12/25/2009
Username2/Password2/Thu 12/24/2009
Username3/Password3/Wed 12/23/2009 etc.....
When I run this check.bat it should compare the current system date for eg: 12/25/2009 with every entry from this dates.txt file specified above. And should return a date which is 48 hrs before. So If I run today (12/25/2009) I should get dates which are equal and less than 12/23/2009).
3. I don't know how to do this: Currently my check.bat looks like this :
@echo off
setlocal
set value=
for /f "tokens=*" %%a in ('type C:\Demo\dates.txt 2^>NUL') do set value=%%a
echo value=%value%
@echo %value%
Thanks.