Introduction: Batch File Address Book V 1

About: I enjoy anything to do with computers. I have made some interesting scripts, and I am constantly improving my skill set. One day I hope to become a programmer, although in what category is still a mystery (al…
I know, I know. You can make anything into an address book, why should you make a batch file into one. Well, the simple answer is: Leave now, this isn't the instructable for you. The other answer is: I had the idea when I was getting my hair cut, its been nagging me ever since and I decided to make it a reality. I had minimal trouble with it, a few rough edges that needed sanding, but other than that, pretty straight forward.

Now, onto the programme's abilities. In this file you can:
1.Add a contact with several peices of information including (but not limited to): Home number, mobile, address, other address (optional), first and last names, birthdays and email addresses. You can add as many contacts as your computer's memory will allow (which is better than the normal contact books).
2.View a contacts details
3.Delete a contact's details.

Now, onto the code.

Step 1: Code

Enter the following code into notepad and name it "Address Book.bat".

REM INITIAL SETTINGS
@ECHO OFF                             
TITLE LOGIN                           
COLOR 0e                              
CD INFO                               
CLS                                   

REM CHECK FOR A USER
IF NOT EXIST USER.TXT GOTO CREATE_USER
GOTO LOGIN                            

REM CREATING A USER
:CREATE_USER
TITLE WELCOME                         
CLS
ECHO THIS APPEARS TO BE YOUR FIRST TIME USING THIS PROGRAMME 
ECHO.                                 
ECHO WE NEED YOU TO MAKE YOUR PROFILE
ECHO.
ECHO PLEASE KEEP IN MIND THAT YOUR PERSONAL DATA WILL ONLY BE ACCESIBLE VIA YOUR COMPUTER
ECHO.
SET /P USER=TYPE YOUR PREFFERED USERNAME HERE:        
SET /P NAME=TYPE YOUR REAL NAME HERE:
ECHO.
SET /P PASS=TYPE YOUR PREFFERED PASSWORD HERE:
SET /P PASS2=RETYPE YOUR PASSWORD HERE:
REM MAKING SURE THE TWO PASSWORDS ARE THE SAME
IF %PASS% NEQ %PASS2% GOTO DIFF       
GOTO CONFIRM     

REM SCENARIO WHEN YOU ENTER TWO DIFFERENT PASSWORDS
:DIFF
CLS
ECHO THE PASSWORDS YOU HAVE ENTERED DO NOT MATCH
ECHO.
ECHO PRESS ANY KEY TO GO BACK TO THE USER CREATION SCREEN
PAUSE >NUL                           
GOTO CREATE_USER

REM CONFIRMING YOUR DATA
:CONFIRM
CLS
ECHO PLEASE CONFIRM YOUR USER SETTINGS
ECHO USERNAME=%USER%                
ECHO NAME=%NAME%
ECHO PASSWORD=%PASS%
ECHO.
ECHO.
ECHO DO YOU WANT TO KEEP THESE SETTINGS? (Y/N)
CHOICE /C YN /N                     
IF %ERRORLEVEL% EQU 1 GOTO CREATE_FILES 
GOTO CREATE_USER

REM CREATING THE FILES TO SUSTAIN THE PROGRAMME
:CREATE_FILES
IF EXIST INFO RMDIR INFO            
MD INFO                             
CD INFO
ECHO :: > "USER.TXT"                
ECHO This text document is to verify that you have a user profile, if you delete it you will lose all of your data. >> "USER.TXT"
ECHO :: > "DATA.BAT"
ECHO SET PASSWORD=%PASS% >> "DATA.BAT" 
ECHO SET NAME=%NAME% >> "DATA.BAT"
ECHO SET USER=%USER% >> "DATA.BAT"
ATTRIB +R USER.TXT                    
GOTO WELCOME

REM LOGIN
:LOGIN
CD INFO
CALL DATA.BAT                         
CLS
ECHO PLEASE ENTER YOUR USERNAME
SET /P USERNAME=
IF %USERNAME% NEQ %USER% GOTO DIF
CLS
ECHO PLEASE ENTER YOUR PASSWORD
SET /P PASS=
IF %PASS% NEQ %PASSWORD% GOTO DIF
GOTO WELCOME

REM THE SCENARIO WHEN YOUR USERNAME/PASSWORD IS INCORRECT
:DIF
CLS
ECHO IT SEEMS YOUR PASSWORD OR USERNAME WAS INCORRECT
ECHO.
ECHO PRESS ANY KEY TO TRY AGAIN
PAUSE >NUL
GOTO LOGIN

REM WELCOMING TO THE PROGRAMME
:WELCOME
CLS
ECHO WELCOME %NAME%
ECHO.
ECHO LOADING YOUR PERSONAL SETTINGS[ 10%
PING LOCALHOST -n 2 >NUL                   
CLS
ECHO WELCOME %NAME%
ECHO.
ECHO LOADING YOUR PERSONAL SETTINGS[][ 30%
PING LOCALHOST -n 2 >NUL
CLS
ECHO WELCOME %NAME%
ECHO.
ECHO LOADING YOUR PERSONAL SETTINGS[][][ 50%
PING LOCALHOST -n 2 >NUL
CLS
ECHO WELCOME %NAME%
ECHO.
ECHO LOADING YOUR PERSONAL SETTINGS[][][][ 70%
PING LOCALHOST -n 2 >NUL
CLS
ECHO WELCOME %NAME%
ECHO.
ECHO LOADING YOUR PERSONAL SETTINGS[][][][] 80%
PING LOCALHOST -n 2 >NUL
CLS
ECHO LOADING YOUR PERSONAL SETTINGS[][][][][] 100%
PING LOCALHOST -n 3 >NUL
CLS
ECHO DONE!
PING LOCALHOST -n 3 >NUL
GOTO MAIN


REM WHERE THE MAGIC HAPPENS
:MAIN
TITLE ADDRESS BOOK V 1
CLS
ECHO WHAT WOULD YOU LIKE TO DO?
ECHO.
ECHO 1) ADD A CONTACT
ECHO 2) DELETE A CONTACT
ECHO 3) SEARCH FOR A CONTACT
SET /P MENU=
IF %MENU% EQU 1 GOTO ADD
IF %MENU% EQU 2 GOTO DEL
IF %MENU% EQU 3 GOTO VIEW
GOTO ERROR

REM WHERE YOU ADD A CONTACT
:ADD
SET OTHERA=0
SET SK1=0
SET SK2=0
SET SK3=0
SET SK4=0
SET SK5=0
SET SK6=0
SET SK7=0
SET SK8=0
SET SK9=0
CLS
ECHO DO NOT USE SPACES! USE UNDERSCORES (_) INSTEAD!
ECHO YOU HAVE CHOSEN TO ADD A CONTACT
ECHO.
ECHO TYPE SKIP IF YOU DON'T WANT A CERTAIN ASPECT TO BE RECORDED. ITEMS MARKED WITH A
ECHO * ARE COMPULSORY
SET /P FNAME=FIRST NAME*:
IF %FNAME% EQU SKIP SET SK1=1
SET /P LNAME=LAST NAME*:
IF %LNAME% EQU SKIP SET SK2=1
SET /P HNUM=HOME NUMBER:
IF %HNUM% EQU SKIP SET SK3=1
SET /P MNUM=MOBILE NUMBER:
IF %MNUM% EQU SKIP SET SK4=1
SET /P HOME=HOME ADDRESS:
IF %HOME% EQU SKIP SET SK5=1
SET /P OTHERA=OTHER ADDRESS:
IF %OTHERA% EQU SKIP SET SK6=1
IF %OTHERA% NEQ 0 SET /P SPECA=PLEASE SPECIFY*: (USE UNDERSCORES (_) FOR SPACES)
IF %SPECA% EQU SKIP SET SK7=1
SET /P EMAIL=EMAIL:
IF %EMAIL% EQU SKIP SET SK8=1
SET /P BDAY=BIRTHDAY:
IF %BDAY% EQU SKIP SET SK9=1
GOTO ADD2

REM CONTACT'S FILE IS BEING CREATED
:ADD2
CD INFO
CLS
ECHO :: > "%LNAME%, %FNAME%.BAT"
ECHO SET FNAME=%FNAME% >> "%LNAME%, %FNAME%.BAT"
ECHO SET LNAME=%LNAME% >> "%LNAME%, %FNAME%.BAT"
IF %SK3% EQU 0 ECHO SET HNUM=%HNUM% >> "%LNAME%, %FNAME%.BAT"
IF %SK4% EQU 0 ECHO SET MNUM=%MNUM% >> "%LNAME%, %FNAME%.BAT"
IF %SK5% EQU 0 ECHO SET HOME=%HOME% >> "%LNAME%, %FNAME%.BAT"
IF %SK6% EQU 0 ECHO SET OTHERA=%OTHERA% >> "%LNAME%, %FNAME%.BAT"
IF %SK7% EQU 0 ECHO SET SPECA=%SPECA% >> "%LNAME%, %FNAME%.BAT"
IF %SK8% EQU 0 SET EMAIL=%EMAIL% >> "%LNAME%, %FNAME%.BAT"
IF %SK9% EQU 0 SET BDAY=%BDAY% >> "%LNAME%, %FNAME%.BAT"
GOTO SUC1

REM LAST CHECK
:SUC1
CLS
ECHO PLEASE CHECK OVER THE DETAILS
CALL %LNAME%, %FNAME%.BAT
ECHO.
ECHO.
ECHO FIRST NAME:%FNAME%
ECHO LAST NAME:%LNAME%
IF %SK3% EQU 0 ECHO HOME NUMBER:%HNUM%
IF %SK4% EQU 0 ECHO MOBILE NUMBER:%MNUM%
IF %SK5% EQU 0 ECHO HOME ADDRESS:%HOME%
IF %SK6% EQU 0 ECHO OTHER ADDRESS:%OTHERA% (%SPECA%)
IF %SK8% EQU 0 ECHO EMAIL ADDRESS:%EMAIL%
IF %SK9% EQU 0 ECHO BIRTHDAY:%BDAY%
ECHO.
ECHO.
ECHO PRESS ANY KEY TO RETURN TO MAIN
PAUSE >NUL
GOTO MAIN

REM SEARCH FOR A CONTACT TO DELETE
:DEL
CD INFO
CLS
ECHO YOU HAVE CHOSEN TO DELETE A CONTACT
ECHO PRESS E TO EXIT (REMEMBER CAPITALS)
ECHO.
ECHO.
SET /P FIRST=FIRST NAME:
SET /P LAST=LAST NAME:
IF EXIST "%LAST%, %FIRST%.BAT" GOTO DEL
CLS
ECHO NO CONTACT OF THAT NAME WAS FOUND, CHECK YOUR SPELLING.
ECHO PRESS ANY KEY TO GO BACK
PAUSE >NUL
GOTO DEL

REM WHERE YOU DELETE THE CONTACT
CLS
ECHO ARE YOU SURE YOU WANT TO DELETE %FIRST% %LAST%'S CONTACT? (Y/N)
CHOICE /C YN /N
IF %ERRORLEVEL% EQU 1 DEL "%LAST%, %FIRST%.BAT"
ECHO PRESS ANY KEY TO RETURN
PAUSE >NUL
GOTO DEL

REM WHERE YOU VIEW A CONTACT'S DETAILS
:VIEW
SET LNAME=
SET FNAME=
SET HNUM=
SET MNUM=
SET EMAIL=
SET HOME=
SET BDAY=
SET OTHERA=
SET SPECA=
CD INFO
CLS
ECHO YOU HAVE CHOSEN TO VIEW A CONTACT'S DETAILS
ECHO TYPE E TO GO BACK TO MAIN
ECHO.
ECHO.
SET /P FIRST=FIRST NAME:
IF %FIRST% EQU E GOTO MAIN
SET /P LAST=LAST NAME:
IF EXIST "%LAST%, %FIRST%.BAT" GOTO EXIST
CLS
ECHO NO CONTACTS WERE FOUND UNDER THAT NAME, SORRY
ECHO.
ECHO PRESS ANY KEY TO SEARCH AGAIN
PAUSE >NUL
GOTO VIEW

REM WHERE YOU GO IF THE CONTACT EXISTS
:EXIST
CALL "%LAST%, %FIRST%.BAT"
CLS
ECHO .%FNAME% %LNAME%
ECHO .%HNUM%
ECHO .%MNUM%
ECHO .%HOME%
ECHO .%OTHERA% %SPECA%
ECHO .%EMAIL%
ECHO .%BDAY%
ECHO.
ECHO PRESS ANY KEY TO RETURN
PAUSE >NUL
GOTO MAIN

:ERROR
CLS
ECHO AN ERROR HAS BEEN REPORTED
ECHO.
ECHO PRESS ANY KEY TO GO TO THE MAIN SCREEN
PAUSE >NUL
GOTO MAIN

As you may be able to see, I have tried to describe what each section does by way of the "REM" command.
Developers might find this helpful when editing the program.  

Step 2: Statisitics

The code takes up 292 lines, consisting of 7206 characters (including spaces). That's about 24.68 characters/line of code.

That's it. Have fun?

Keep in mind that only the first picture is mine, the rest I selected at random from a google image search.