I have a File named as Account.txt which contains the following data
Joey 1990
Gordon 1984
Clint 1992
What I would like to do is check if the username inputted by the user matches with the above names.
Upto now I am able to write this up
@echo off
:CheckUser
set /p Uid="User: "
echo %uid%
set detailslocation=C:\Users\Troy\Desktop\Accounts.txt
findstr /m "\<%uid%\>" "%detailslocation%" >nul 2>&1
if %errorlevel% == 0 goto NextFunction
color c
echo Invalid User ID. Please enter again
cls
goto CheckUser
The above code is an extracted from the Batch File I am trying to develop.
What I intend to do is check if the username inputted by the user matches with one in Accounts.txt (ie. the First word on every line)
The problem with above code is that it will work if I enter Joey (or any of the names mentioned). However it also accepts 1990 or 1984 or 1992. How do I limit it to check for only the first word of every line and not the second word.
Thanks. Also I am not a programmer by profession, So I would appreciate if you could explain me the reasoning behind your piece of code.