I created this batch file for a little mom and pops shop in the local area and I thought here would be a great place to post it. This is a simple little Time Clock batch file. It is comprised in two parts; one for recording the time, another for admin purposes. Feel free to play around with it, improve it, leave feedback, and hopefully we can all learn something new.
Timeclock.bat:
@echo offcolor 0Fmode con cols=45 lines=3Title Time ClockSet mm=%DATE:~4,2%Set dd=%DATE:~7,2%Set yy=%DATE:~10,4%:nameclsecho %mm%-%dd%-%yy% %time%set /p name=Enter Your Name:if %name%==admin goto adminset /p input=Enter Employee Number:findstr %input% Employees.txt > temp1.txtfindstr %name% Employees.txt > temp2.txtgoto next:nextset /p comp=<temp1.txtif %input%==%comp% goto thengoto error:thenset /p com=<temp2.txtif %name%==%com% goto menugoto error:menudel temp1.txtclsecho 1. Clock In?echo 2. Clock out?set /p c=if "%c%"=="1" goto inif "%c%"=="2" goto out:inecho %name%,%input%,IN,%time%,%date% >> "%userprofile%\Desktop\%mm%-%dd%-%yy%.csv"goto end:outecho %name%,%input%,OUT,%time%,%date% >> "%userprofile%\Desktop\%mm%-%dd%-%yy%.csv"goto end:admincall admin.bat:errorecho Your input does not match our records please try againecho.pausegoto name:end<temp1.txt< div="">
<temp2.txt< div="">
Admin.bat:</temp2.txt<>
@echo offcolor 0Fmode con cols=45 lines=3:adminif exist pass.txt (goto login) else (goto create):loginset /p pass=Enter Password:findstr %pass% pass.txt > temp.txtset /p comp=<temp.txtgoto next:nextif %pass%==%comp% goto panelgoto login:createclsset /p pass=Create Password:echo %pass% >> pass.txtattrib +h pass.txtgoto panel:panelmode con cols=45 lines=10del temp.txtclsecho 1. Set Up Employeeecho 2. Remove Employeesecho 3. View Employeesecho 4. Add Passwordecho 5. Delete Passwordsecho 6. View Current Timesecho 7. Quitecho.set /p C=if "%C%"=="1" goto employeeif "%C%"=="2" goto removeif "%C%"=="3" goto viewcheckif "%C%"=="4" goto newpassif "%C%"=="5" goto delpassif "%C%"=="6" goto timecheckif "%C%"=="7" goto quit:employeeclsset /p emp=Enter Employee Name:set /p num=Enter Employee Number:findstr %num% Employees.txt >> temp.txtset /p comp=<temp.txtdel temp.txtif %num%==%comp% goto errorsgoto employees:employeesecho %emp% >> Employees.txtecho %num% >> Employees.txtecho. >> Employees.txtattrib +h Employees.txtecho Add another employee?echo 1. Yesecho 2. Noset /p add=if "%add%"=="1" goto employeeif "%add%"=="2" goto panel:viewclstype Employees.txtecho.pausegoto panel:newpassclsset /p pass=Create Password:echo %pass% >> pass.txtgoto panel:timesclstype time.txtpausegoto panel:delpassdel pass.txtgoto create:timecheckif exist time.txt (goto time) else (goto error):viewcheckif exist Employees.txt (goto view) else (goto error):errorclsecho I am sorry it does not seem like that file exist yet.pausegoto panel:errorsclsecho I am sorry that employee number is already in use. Please try another.pausegoto employee:removemode con cols=45 lines=5set /p z=Enter Employee Name:clsattrib -h -a Employees.txtfindstr /v %z% Employees.txt >> temp.txtdel Employees.txtfindstr .* temp.txt >> Employees.txtdel temp.txtattrib +h +a Employees.txtecho Remove Another Employee?echo 1. Yesecho 2. Noset /p a=if "%a%"=="1" goto removeif "%a%"=="2" goto panel:quit</temp1.txt<>

