Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for today.bat

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

  1. @GOTO Run
  2.  
  3. o 70 06
  4. i 71
  5. o 70 07
  6. i 71
  7. o 70 08
  8. i 71
  9. o 70 09
  10. i 71
  11. o 70 32
  12. i 71
  13.  
  14. q
  15.  
  16. :Run
  17. @ECHO OFF
  18. SETLOCAL ENABLEDELAYEDEXPANSION
  19. SET Weekday.00=Saturday
  20. SET Weekday.01=Sunday
  21. SET Weekday.02=Monday
  22. SET Weekday.03=Tuesday
  23. SET Weekday.04=Wednesday
  24. SET Weekday.05=Thursday
  25. SET Weekday.06=Friday
  26. SET Weekday.07=Saturday
  27. SET Params=0
  28. SET Delim=
  29. SET Sorted=1
  30. SET Weekday=0
  31. SET W=
  32. SET D=
  33. SET M=
  34. SET Y=
  35. SET C=
  36. ECHO.%* | FINDSTR /R /C:"[/-]?" >NUL && GOTO Syntax
  37. ECHO %~1 | FINDSTR /R /B /C:"/" >NUL
  38. IF ERRORLEVEL 1 (
  39. 	SET Delim=%~1
  40. 	SET /A Params += 1
  41. ) ELSE (
  42. 	IF "%~1"=="/" SET Delim=/
  43. )
  44. ECHO.%* | FIND /I "/NS" >NUL
  45. IF NOT ERRORLEVEL 1 (
  46. 	SET Sorted=0
  47. 	SET /A Params += 1
  48. )
  49. ECHO.%* | FIND /I "/WN" >NUL
  50. IF NOT ERRORLEVEL 1 (
  51. 	SET Weekday=1
  52. 	SET /A Params += 1
  53. )
  54. ECHO.%* | FIND /I "/WS" >NUL
  55. IF NOT ERRORLEVEL 1 (
  56. 	SET Weekday=2
  57. 	SET /A Params += 1
  58. )
  59. IF %Params% GTR 0 SET /A Params += 1
  60. IF "%Params%" GTR 1 CALL IF NOT "%%~%Params%"=="" GOTO Syntax
  61.  
  62. FOR /F "skip=1" %%A IN ('DEBUG ^< "%~fs0" ^| FIND /V "-"') DO (
  63. 	IF "!W!"=="" (
  64. 		SET W=%%A
  65. 	) ELSE (
  66. 		IF "!D!"=="" (
  67. 			SET D=%%A
  68. 		) ELSE (
  69. 			IF "!M!"=="" (
  70. 				SET M=%%A
  71. 			) ELSE (
  72. 				IF "!Y!"=="" (
  73. 					SET Y=%%A
  74. 				) ELSE (
  75. 					SET C=%%A
  76. 				)
  77. 			)
  78. 		)
  79. 	)
  80. )
  81.  
  82. IF "%Sorted%"=="1" (SET Today=%C%%Y%%Delim%%M%%Delim%%D%) ELSE (SET Today=%D%%Delim%%M%%Delim%%C%%Y%)
  83. IF "%Weekday%"=="1" SET Today=%W% %Today%
  84. IF "%Weekday%"=="2" SET Today=!Weekday.%W%! %Today%
  85. ECHO.%Today%
  86.  
  87. ENDLOCAL
  88. GOTO:EOF
  89.  
  90. :Syntax
  91. ECHO Today.bat,  Version 1.10 for Windows 2000 and later
  92. ECHO Display the current date with your choice of delimiter
  93. ECHO.
  94. ECHO Usage:    TODAY  [ delimiter ]  [ /NS ]  [ /WN ^| /WS ]
  95. ECHO.
  96. ECHO Where:    delimiter  is any character or string to be used as output delimiter
  97. ECHO           /NS        displays date in DD MM YYYY order ^(default is YYYY MM DD^)
  98. ECHO           /WN        displays the day of the week too, as a number
  99. ECHO           /WS        displays the day of the week too, as a string
  100. ECHO.
  101. FOR /F "tokens=1-5" %%A IN ('%~sf0 ^" ^" /WN') DO (
  102. 	ECHO Returns:  %%A %%B %%C %%D ^(weekday YYYY MM DD^) with any delimiter you choose
  103. 	ECHO.
  104. 	ECHO Examples: TODAY - /NS /WS -^>  !Weekday.%%A! %%D-%%C-%%B
  105. 	ECHO           TODAY / /WN     -^>  %%A %%B/%%C/%%D
  106. 	ECHO           TODAY " " /NS   -^>  %%D %%C %%B
  107. 	ECHO           TODAY           -^>  %%B%%C%%D
  108. )
  109. ECHO.
  110. ECHO Sources:
  111. ECHO http://mirror.href.com/thestarman/asm/debug/debug2.htm
  112. ECHO http://www.plasma-online.de/textual/download/misc/cmos_registers.html
  113. ECHO.
  114. ECHO Written by Rob van der Woude
  115. ECHO http://www.robvanderwoude.com
  116.  

page last modified: 2024-04-16; loaded in 0.0059 seconds