Im working on creating a batch file that will make a fake profile from a list of names and generate random dates of birth. I have the dates of birth down but when I try to run this code, the out put for %FName% is always (Zachary) the last line of my text file, and %LName% always equals Dora, the last line of the other file. I do not know why this is happening. Ive looked at this but I cant seem to find the problem. The list of names is a simple:
Bob
Billy
Jacob
Andrew
Vince
Here is the code:
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
:start
:FName
cls
set "lines=0"
for /f "tokens=*" %%a in (GivenNames.txt) do set /a "lines+=1"
set /a "skip=%random% %% lines"
if %skip% lss 1 (set "skip=") else (set "skip=skip=%skip%")
for /f "%skip% tokens=*" %%a in (GivenNames.txt) do set "FName=%%a"
goto LName
:LName
cls
set "lines=0"
for /f "tokens=*" %%a in (Surnames.txt) do set /a "lines+=1"
set /a "skip=%random% %% lines"
if %skip% lss 1 (set "skip=") else (set "skip=skip=%skip%")
for /f "%skip% tokens=*" %%a in (Surnames.txt) do set "LName=%%a"
goto MName
:MNAme
cls
set alfanum=ABCDEFGHIJKLMNOPQRSTUVWXYZ
set middle=
FOR /L %%b IN (0, 1, 16) DO (
SET /A rnd_num=!RANDOM! * 26 / 32768 + 1
for /F %%c in ('echo %%alfanum:~!rnd_num!^,1%%') do set MName=!pwd!%%c
)
goto compilename
:compilename
cls
set fullname=%FName% %MName%. %LName%
cls
echo %fullname%
pause>nul
goto start
Example output:
Zachary I. Dora
What I need:
"Random First Name From List" "Random Letter". "Random Last Name From List"
Thanks in advance, -Zackary