Skip to content

Instantly share code, notes, and snippets.

@prasadrahul
Last active October 24, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasadrahul/0a5c821f1a7146b146344f7573de3b06 to your computer and use it in GitHub Desktop.
Save prasadrahul/0a5c821f1a7146b146344f7573de3b06 to your computer and use it in GitHub Desktop.
[code language="Batch"]
@echo OFF
::###################################################
::NOTE:- This script can with in month Range only #
::###################################################
::------------------------------------------------------
::SET Today=%Date:~10,4%-%Date:~4,2%-%Date:~7,2%
:: ^ ^ ^ ^ ^
:: | | | | |
:: Year | Dash Month Day
:: |
:: Number of chars
::------------------------------------------------------
echo #=#=#=#=#=#=#=#=#=#=#=#=#=#=#
echo Current Date is : %DATE%
echo ######################################
::Set Start Time HH:MM
set wDEMOTIME=12:45
::Set Start DATE dd-mm-yyyy
set wSTARTDATE=05-16-2015
::Set END DATE dd-mm-yyyy
set wENDDATE=05-18-2015
echo Start Date is: %wSTARTDATE%
echo End Date is: %wENDDATE%
echo ######################################
::Variable for Start Time setup
set sHOUR=%wDEMOTIME:~0,2%
set sMINUTE=%wDEMOTIME:~3,2%
::Variable for start date setup
set sMONTH=%wSTARTDATE:~0,2%
set sDATE=%wSTARTDATE:~3,2%
set sYEAR=%wSTARTDATE:~6,4%
::Variable for end date setup
set eMONTH=%wENDDATE:~0,2%
set eDATE=%wENDDATE:~3,2%
set eYEAR=%wENDDATE:~6,2%
ECHO Enter Either Y or N:
CHOICE /M "Do yo really want to quit"
::Keep level in decreasing order
IF ERRORLEVEL 2 Goto Nop
IF ERRORLEVEL 1 Goto Yes
Goto End
echo PWD: %cd%
:Yes
FOR /L %%d IN (%sDATE%,1,%eDATE%) DO (
:: Changing Date
Date %%d-%sMONTH%-%sYEAR%
:: Changing Time
Time %sHOUR%:%sMINUTE%
echo Running required commands
::Here ==> Run required task with in date and time Range
)
Goto End
:Nop
echo Exit the command promt
:End
pause
[/code]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment