Thursday, December 8, 2011

How to use date and if statement in a batch file?

Hi friends,


I need to perform an operation based on a particular date. Please check out this program in DOS.





@echo off


c:


cd \


attrib -r -a -s -h abc


del abc





I need this set of statements to be executed only on 1st of any month. So, how can I do that using a MS DOS batch file?





i.e.,


if (today's date == 1)


{


execute those set of statements;


}





Vasanth|||There was an error in the previous message.


@echo off


cd\


if %date:~4,2% equ 01 goto MESSAGE


echo not the 1st of month


goto END


:MESSAGE


echo the 1st of month


:END


Try this out!!!





Praveen|||echo off


cd\


if %date:~4,2% equ 01 goto MESSAGE


echo not the 1st of month


goto END


MESSAGE


attrib -r -a -s -h abc


del abc


END








try this out... may b this is what u want

No comments:

Post a Comment