Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sorttime.bat

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

  1. @ECHO OFF
  2. IF NOT "%1"=="" GOTO Syntax
  3.  
  4. :: Use BATCHMAN to retrieve day
  5. BATCHMAN DAY
  6. :: Errorlevel 0 means BATCHMAN was not found
  7. IF NOT ERRORLEVEL 1 GOTO NotFound
  8.  
  9. :: Use BATCHMAN to retrieve hour
  10. BATCHMAN HOUR
  11. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL  %%A SET HH=0%%A
  12. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 1%%A SET HH=1%%A
  13. FOR %%A IN (0 1 2 3)             DO IF ERRORLEVEL 2%%A SET HH=2%%A
  14.  
  15. :: Use BATCHMAN to retrieve minutes
  16. BATCHMAN MINUTE
  17. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL  %%A SET MM=0%%A
  18. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 1%%A SET MM=1%%A
  19. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 2%%A SET MM=2%%A
  20. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 3%%A SET MM=3%%A
  21. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 4%%A SET MM=4%%A
  22. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 5%%A SET MM=5%%A
  23.  
  24. :: Use BATCHMAN to retrieve seconds
  25. BATCHMAN SECOND
  26. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL  %%A SET SS=0%%A
  27. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 1%%A SET SS=1%%A
  28. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 2%%A SET SS=2%%A
  29. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 3%%A SET SS=3%%A
  30. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 4%%A SET SS=4%%A
  31. FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL 5%%A SET SS=5%%A
  32.  
  33. :: Store in variable and clean up temporary variables
  34. SET SortTime=%HH%%MM%%SS%
  35. SET HH=
  36. SET MM=
  37.  
  38. :: Display the result
  39. ECHO.
  40. ECHO SortTime = %SortTime%
  41. GOTO End
  42.  
  43. :Syntax
  44. ECHO.
  45. ECHO SortTime.bat,  Version 1.00 for MS-DOS
  46. ECHO Display the current time in HHmmss format
  47. ECHO.
  48. ECHO Usage:  SORTTIME
  49. ECHO.
  50. ECHO This batch file uses BATCHMAN, a utility by Michael Mefford
  51. ECHO.
  52. ECHO Written by Rob van der Woude
  53. ECHO http://www.robvanderwoude.com
  54.  
  55. :End
  56.  

page last uploaded: 2017-07-06, 12:37