Advertisement
FlyFar

Batch/CMD Timer: A tool help you count time

Oct 21st, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.03 KB | None | 0 0
  1. REM This script measures time
  2. chcp 65001
  3. echo off
  4. title Script to measure time
  5. cls
  6. :start
  7. echo ┌────────────────────────────────────┐
  8. echo │Press enter to START measuring time.│
  9. echo └────────────────────────────────────┘
  10. set /p sessionTitle="Set timer session title or press enter >"
  11. if not defined sessionTitle (set sessionTitle=unnamed session)
  12. call :tstart
  13. title Measuring time... %sessionTitle%
  14. REM Saving start to log file
  15. echo %date% - %sessionTitle%>> timelog.log
  16. echo  ╔═══════════════════════╦═══════════╗>> timelog.log
  17. echo  ║Time of initialization ║%starttime%║  Total time:>> timelog.log
  18. REM End of log file print
  19. echo.
  20. echo ┌─────────────────────────────────────────────┐
  21. echo │Now press any key to STOP and display result.│
  22. echo └─────────────────────────────────────────────┘
  23. pause
  24. call :tstop
  25. title Script to measure time... %sessionTitle%
  26. echo.
  27. echo ───────────────────────────────────────────────
  28. call :timer
  29. goto start
  30. REM timer
  31. :tstart
  32. set starttime=%time%
  33. goto eof
  34. :tstop
  35. set endtime=%time%
  36. goto eof
  37. :timer
  38. set/a hour= %endtime:~0,2% - %starttime:~0,2%
  39. set/a min= %endtime:~3,2% - %starttime:~3,2%
  40. set/a sec= %endtime:~6,2% - %starttime:~6,2%
  41. set/a cents= %endtime:~-2% - %starttime:~-2%
  42. if %cents:~0,1% == - ( set/a sec -= 1 && set/a cents += 100 )
  43. if %sec:~0,1% == - ( set/a min -= 1 && set/a sec += 60 )
  44. if %min:~0,1% == - ( set/a hour -= 1 && set/a min += 60 )
  45. if %hour:~0,1% == - ( set/a hour += 24 )
  46. echo Rendering timer:
  47. echo  ╔═══════════════════════╦═══════════╗  Total time:
  48. echo  ║Time of initialization ║%starttime%║   hours .............. %hour%
  49. echo  ╟───────────────────────╫───────────╢   minutes ............ %min%
  50. echo  ║   Time of execution   ║%endtime%║   seconds ............ %sec% %cents%/100
  51. echo  ╚═══════════════════════╩═══════════╝
  52. REM Saving to log file
  53. echo  ╟───────────────────────╫───────────╢   hours .............. %hour% >> timelog.log
  54. echo  ║   Time of execution   ║%endtime%║   minutes ............ %min% >> timelog.log
  55. echo  ╚═══════════════════════╩═══════════╝   seconds ............ %sec% %cents%/100>> timelog.log
  56. echo.>> timelog.log
  57. goto eof
  58. rem Written By FlyFar
  59. :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement