Jump to content

What do you think of this batch script?


Dicecaster

Recommended Posts

So, I play a lot of computer games, and I decided that I wanted to make a program that let me catalog all the games I own. Thankfully, batch scripting did the trick. Here it is:

 

@echo off

title Game Explorer

color 0a

 

:command

cls

echo Commands:

echo,

echo list - shows a complete list of catalogued games.

echo add - walks you throught the process of cataloguing a new game.

echo view - view the information of the specified game.

echo delete - delete a game from the database.

echo color - change the background and text colors

echo info - displays information about Game Explorer.

echo,

set /p cmnd=Enter command:

cls

if "%cmnd%"=="list" goto list

if "%cmnd%"=="add" goto add

if "%cmnd%"=="view" goto view

if "%cmnd%"=="delete" goto delete

if "%cmnd%"=="color" goto color

if "%cmnd%"=="exit" exit

if "%cmnd%"=="info" (

goto info

) else (

goto command

)

 

:list

tree /f c:\games

pause

goto command

 

:add

set /p name=What is the game's name?

set /p genre=To what genre does the game belong?

set /p descrip=If you'd like, enter a description for the game:

echo Name: %name% > "c:\games\%name%"

echo Genre: %genre% >> "c:\games\%name%"

echo Description: %descrip% >> "c:\games\%name%"

goto command

 

:view

set /p game=What game would you like to view?

if exist "c:\games\%game%" (

cls

type "c:\games\%game%"

) else echo That game doesn't exist or you made a typing error.

echo,

pause

goto command

 

:delete

set /p game=What game file do you want to delete?

del "c:\games\%game%"

goto command

 

:color

echo Here are the color codes:

echo 0 = Black 8 = Gray

echo 1 = Blue 9 = Light Blue

echo 2 = Green A = Light Green

echo 3 = Aqua B = Light Aqua

echo 4 = Red C = Light Red

echo 5 = Purple D = Light Purple

echo 6 = Yellow E = Light Yellow

echo 7 = White F = Bright White

set /p b=Enter the background color:

set /p f=Enter the text color:

color %b%%f%

goto command

 

:info

echo Game Explorer is a small program that allows you to catalogue and view computer games. I've created it so that you can view all your games in a breeze. It comes with six commands: list, add, view, delete, info, and color. List shows you a list of all the games you've catalogued using Game Explorer. Add allows you to catalogue individual games, guiding you through the process. It can also be used to rewrite previously catalogued games. View displays information about a game you specify, if it exists (like start). Delete works like view, except it deletes the information for one of the games. And you know what info does. Color guides you through a process to change the color of the background and the color of the text.

echo,

echo Note: When writing the title in the game-adding process, don't use special characters (colon, exclamation mark, etc.). These will cause errors to occur.

echo,

pause

goto command

 

So, tell me what you think. Oh, and when I try to add a game, when I use a colon in the title it erases all the other data I input for that game. Does anyone know how I can fix this (or at least why it happens)?

Edited by Dicecaster
Link to comment
Share on other sites

First, go to "My Computer", open drive C (C:\), and make a folder called "GAMES".

 

Then copy and paste it into Notepad, save it as "anything.bat" and start it. Type "info", hit enter, and it will explain how it all works.

 

P.S. I changed the script so it will work with these instructions.

Edited by Dicecaster
Link to comment
Share on other sites

nice.. how about you make a program? with a nice interface? with images and stuff?

 

Edit: have a look at the attachment, a prezzie for you!

If you look at my signature, it has a link to the AKH Batch File to EXE Converter. I used that to make it into an actual program (using the blue icon). I don't know of any icons that would be suitable, but I think I'll look around. Thanks.

 

P.S. I didn't know that they would allow you to attach .zip files. I would probably have put the .exe in, but it doesn't allow you too. Thanks.

Link to comment
Share on other sites

Scratch that, it allows all attachment files. It just doesn't allow attachments for signatures. Here's my .exe:

 

Extract it. See the blue icon?

 

P.S. How'd you make yours into an application?

Link to comment
Share on other sites

I used a tool. Thats what i used: http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html

let me find a good icon for you

Alright, thanks. I really meant it just for personal use, but if you find a good icon, thanks a lot.

 

Actually, if you happen to know anywhere where I can "publish" programs I make (batch or other), please let me know.

Link to comment
Share on other sites

You'd probably do better to use a more functional programming language for something like this. Using ancient MS-DOS batch scripts seems a little silly, and is a lot of extra effort for nothing. Try writing it in C# or Java - you can probably do the same kind of thing much better, in less lines of code, and can add in all kinds of extra functionality with ease. If you're using C# in Visual Studio, or Java in Netbeans IDE, you can do a GUI pretty quickly too.

 

Windows Vista and 7 have a game explorer which does something very similar, but adds games automatically when they're installed. It does have a habit of not adding all games though, and theres no way to manually add them that I know of, so this could come in handy if it had equivalent functionality to the default windows one.

Edited by The_Terminator
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...