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 off
color 0F
mode con cols=45 lines=3
Title Time Clock
Set mm=%DATE:~4,2%
Set dd=%DATE:~7,2%
Set yy=%DATE:~10,4%
:name
cls
echo %mm%-%dd%-%yy% %time%
set /p name=Enter Your Name:
if %name%==admin goto admin
set /p input=Enter Employee Number:
findstr %input% Employees.txt > temp1.txt
findstr %name% Employees.txt > temp2.txt
goto next
:next
set /p comp=<temp1.txt
if %input%==%comp% goto then
goto error
:then
set /p com=<temp2.txt
if %name%==%com% goto menu
goto error
:menu
del temp1.txt
cls
echo 1. Clock In?
echo 2. Clock out?
set /p c=
if "%c%"=="1" goto in
if "%c%"=="2" goto out
:in
echo %name%,%input%,IN,%time%,%date% >> "%userprofile%\Desktop\%mm%-%dd%-%yy%.csv"
goto end
:out
echo %name%,%input%,OUT,%time%,%date% >> "%userprofile%\Desktop\%mm%-%dd%-%yy%.csv"
goto end
:admin
call admin.bat
:error
echo Your input does not match our records please try again
echo.
pause
goto name
:end
<temp1.txt< div="">
<temp2.txt< div="">
Admin.bat:
</temp2.txt<>
@echo off
color 0F
mode con cols=45 lines=3
:admin
if exist pass.txt (goto login) else (goto create)
:login
set /p pass=Enter Password:
findstr %pass% pass.txt > temp.txt
set /p comp=<temp.txt
goto next
:next
if %pass%==%comp% goto panel
goto login
:create
cls
set /p pass=Create Password:
echo %pass% >> pass.txt
attrib +h pass.txt
goto panel
:panel
mode con cols=45 lines=10
del temp.txt
cls
echo 1. Set Up Employee
echo 2. Remove Employees
echo 3. View Employees
echo 4. Add Password
echo 5. Delete Passwords
echo 6. View Current Times
echo 7. Quit
echo.
set /p C=
if "%C%"=="1" goto employee
if "%C%"=="2" goto remove
if "%C%"=="3" goto viewcheck
if "%C%"=="4" goto newpass
if "%C%"=="5" goto delpass
if "%C%"=="6" goto timecheck
if "%C%"=="7" goto quit
:employee
cls
set /p emp=Enter Employee Name:
set /p num=Enter Employee Number:
findstr %num% Employees.txt >> temp.txt
set /p comp=<temp.txt
del temp.txt
if %num%==%comp% goto errors
goto employees
:employees
echo %emp% >> Employees.txt
echo %num% >> Employees.txt
echo. >> Employees.txt
attrib +h Employees.txt
echo Add another employee?
echo 1. Yes
echo 2. No
set /p add=
if "%add%"=="1" goto employee
if "%add%"=="2" goto panel
:view
cls
type Employees.txt
echo.
pause
goto panel
:newpass
cls
set /p pass=Create Password:
echo %pass% >> pass.txt
goto panel
:times
cls
type time.txt
pause
goto panel
:delpass
del pass.txt
goto create
:timecheck
if exist time.txt (goto time) else (goto error)
:viewcheck
if exist Employees.txt (goto view) else (goto error)
:error
cls
echo I am sorry it does not seem like that file exist yet.
pause
goto panel
:errors
cls
echo I am sorry that employee number is already in use. Please try another.
pause
goto employee
:remove
mode con cols=45 lines=5
set /p z=Enter Employee Name:
cls
attrib -h -a Employees.txt
findstr /v %z% Employees.txt >> temp.txt
del Employees.txt
findstr .* temp.txt >> Employees.txt
del temp.txt
attrib +h +a Employees.txt
echo Remove Another Employee?
echo 1. Yes
echo 2. No
set /p a=
if "%a%"=="1" goto remove
if "%a%"=="2" goto panel
:quit
</temp1.txt<>