Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for datetime.bat

(view source code of datetime.bat as plain text)

  1. @ECHO OFF
  2. :: DateTime.bat
  3. :: Set environment variables with current Date, Time and DayOfWeek
  4.  
  5. :: Recursion
  6. IF NOT "%3"=="" GOTO SecondTime
  7. :: Create temporary batch file
  8. > TEMPDTT1.BAT ECHO @PROMPT %0 $D $T
  9. :: Do _N_O_T_ replace "COMMAND /C" with CALL in the next line
  10. > TEMPDTT2.BAT COMMAND /C TEMPDTT1.BAT
  11. TEMPDTT2
  12.  
  13. :SecondTime
  14. DEL TEMPDTT?.BAT
  15. SET DOW=%1
  16. SET DATE=%2
  17. SET TIME=%3
  18.  
  19. :: Remove forward slashes from DATE variable and store result in DATE2
  20. IF EXIST DATE2.BAT DEL DATE2.BAT
  21. SET DATE2=
  22. :: Parse DATE variable and create temporary batch
  23. :: file to recreate DATE without forward slashes
  24. >> DATE2.BAT FOR %%A IN (/%DATE%) DO ECHO SET DATE2=%%DATE2%%%%A
  25. CALL DATE2.BAT
  26. DEL  DATE2.BAT
  27.  

page last uploaded: 2017-08-21, 14:26