Last active
July 20, 2018 04:31
-
-
Save mjec/6e4a66abb62b3b338570 to your computer and use it in GitHub Desktop.
Time recording in timelog (*ledger) format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Time recording utility - writes to timelog (*ledger) format. | |
REM A quick hack by Michael Cordover (mjec) | |
REM Released into the public domain. | |
cls | |
echo Time recording utility | |
set /p filename= "Enter file name: " | |
set task= | |
set oldtask= | |
echo. | |
echo Suggested task format: Project Description (note double space) | |
echo. | |
echo Use blank task to exit. Hit any letter or number to stop time recording. | |
echo. | |
:start | |
set oldtask=%task% | |
IF "%oldtask%" == "" GOTO :skipcheckout | |
CALL :SUB_TIME | |
echo [%HH24%:%MI%:%SS%] stopping %oldtask%... | |
echo o %mydate% %HH24%:%MI%:%SS% %oldtask% >> %filename% | |
echo. | |
:skipcheckout | |
echo. | |
set task= | |
set /p task= "Enter task description: " | |
IF "%task%" == "" GOTO :confirmexit | |
CALL :SUB_TIME | |
echo [%HH24%:%MI%:%SS%] starting %task%... | |
echo i %mydate% %HH24%:%MI%:%SS% %task% >> %filename% | |
:timeloop | |
REM This rings the bell every 5 minutes to remind you a task is active. | |
REM Unfortunately it means that you have to press a letter/number to stop | |
REM The alternative is to mvoe stopping to when a new task is created | |
REM (including a blank task). This would mean you can disable the bell | |
REM (say by pressing Q) - and even re-enable it - but it would take a | |
REM new entry to actually terminate time recording. | |
REM This is left as an exercise to the reader ;) | |
choice /c ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789€ /n /t 300 /d € >NUL | |
IF Errorlevel 37 GOTO keeplooping | |
GOTO :start | |
:keeplooping | |
echo|set /p = | |
GOTO :timeloop | |
:confirmexit | |
choice /n /m "Exit? (Y/N)" | |
IF Errorlevel 2 GOTO start | |
IF Errorlevel 1 GOTO myEOF | |
GOTO :myEOF | |
:SUB_TIME | |
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mydate=%%c/%%b/%%a) | |
For /f "tokens=1-4 delims=/:." %%a in ("%TIME%") do ( | |
SET HH24=%%a | |
SET MI=%%b | |
SET SS=%%c | |
SET FF=%%d | |
) | |
EXIT /B | |
:myEOF | |
echo. | |
echo Exiting... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 49 should have an ASCII BEL (\7) after the equals sign. Create in cmd with:
and then copy and paste into position in notpad etc.