Complex Batch Script

Dell / Dell dxp051...
December 20, 2009 at 14:40:52
Specs: Windows 7 Ultimate, 3.192 GHz / 3070 MB
Okay, this is what I have on my plate.

I want to get back into collection data on people for my references and info info.

What I am looking for to do is creating a batch file that will give me a list of queries that I can fill out.

Now a little more detailed.

When done filling out the queries, it out puts them all correctly formatted in the batch file for me / anyone to review the entries (While its busy saving the info in the back).

Its not to jst output to a text file. I want it more detailed then that.

C:\docs\(Gender)\# (# = first letter of last name)\(LAST NAME, FIRST, MIDDLE)


Example Queries:

NAME:
First:
Middle:
Last:

Date Of Birth
Month:
Date:
Year:

-------

And so on, entries can be added later.

Anyways, That is what I am doing and its not going to be easy since I can only code the long way, all the little short cuts and what not that I have seen here is crazy. :D

==========================================

Anyways, this is what I have so far.

:START
@ECHO OFF
@CLS

@Echo What is First name?
SET /P 1a=
@Echo What is Middle name?
SET /P 1b=
@Echo What is Last name?
SET /P 1c=

@CLS
@ECHO His Name Is: %1c% %1a% %1b%
@pause

The problem with this is that the output says 1c1a1b, I want it to say what ever I typed into the "SET /P 1a" and so on.


See More: Complex Batch Script

Report •


#1
December 20, 2009 at 15:26:14
you knw, I think I knw how I could make it. I could make it ask for the entries and when all the entries it is made, I could make a template and for where the enties go, I could put "ent#1" and so on :D

Report •

#2
December 20, 2009 at 15:45:23
Your problem is starting your variable names with numbers. Always start with alphas. No need to first echo the questions. Just include them with the set /p statements.

:START
@ECHO OFF
@CLS


SET /P n1=What is First name?
SET /P n2=What is Middle name?
SET /P n3=What is Last name?

@CLS
ECHO His Name Is: %n1% %n2% %n3%
pause


Report •

#3
December 20, 2009 at 16:03:59
Yes I saw that after a few trial and errors :D I remember now.

Anyways, here is this:


> How it works
- Or how it SHOULD work.


[1] Adding Docs

> Open Bat
- Welcome Screen
-


> Template Selection
- Temp1, temp2, temp3
- Option to view the templates.
- (Its like, I wanna see temp 1, and its like, well okat. So it opens the temp in notepad)


> Fill out query entries on selected template
- Name, address, etc
- The batch will be programmed to check the name against the folders to make sure there isnt an entry already listed in the files (if there is, the operator can overpower that and make a new entry (the batch will back up the already existing entry to the backup folder))
-


> Review Enties
- upon review scree, saving starts
-


> SAVING...
- Puts in correct folder in the right formmat.
- C:\docs\(country)\(gender)\(1st letter of last name)\(Last Name, First, Middle)\(first, middle, last.txt)
- If "\(Last Name, First, Middle)\" folder already exist, the batch will be programed to backup the "(first, middle, last.txt)" text file into the backup directory located in that persons folder.
-


####### BACKGROUND ACTIONS #######

Temps will have "_ent" for ever entry that is needed.

Whats his name? (If the user put "john" the batch will know to replave "name_ent1" with John

When the user puts in his first, middle, and last name, its check for a already existing folder with that name and if its there, it tells the user that there is already a entry for this person. They then have a option to delete it, replace it (which backs it up), or to go back to the main menu

[2] Editing

(I don't know about editing right now)


Report •

Related Solutions

#4
December 20, 2009 at 16:07:28
here you go...

;D

it can safe to file, it wont overwrite the file, so you can add
more persons later if you like...

@echo off
:start
set /p _first= What is the first name? :
set /p _middle= What is the middle name? :
set /p _last= What is the last name? :

echo.
echo His/her name is: %_first% %_middle% %_last%

echo.
echo Set the date of birth.
echo.
set /p _day= The day is? :
set /p _month= The month is? :
set /p _year= The year is? :

echo.
echo Would you like to write this info to a file?
echo.
echo NAME:
echo First : %_first%
echo Middle : %_middle%
echo Last : %_last%
echo.
echo DATE OF BIRTH:
echo Month : %_month%
echo Date : %_day%
echo Year : %_year%
echo.
set /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :error
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no

:error
echo.
echo No valid answer recieved. Try again.
echo.
set /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :repeat
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no

:repeat
goto :error

:yes
echo ----------------------------------------------- >> c:\output.txt
echo NAME: >> c:\output.txt
echo First : %_first% >> c:\output.txt
echo Middle : %_middle% >> c:\output.txt
echo Last : %_last% >> c:\output.txt
echo. >> c:\output.txt
echo DATE OF BIRTH: >> c:\output.txt
echo Month : %_month% >> c:\output.txt
echo Date : %_day% >> c:\output.txt
echo Year : %_year% >> c:\output.txt
echo. >> c:\output.txt
goto :no

:no
echo.
echo Would you like to start a new?
echo.
set /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :error2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" goto :no2
if "%_answer2%"=="N" goto :no2

:error2
echo.
echo No valid answer recieved. Try again.
echo.
set /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :repeat2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" goto :no2
if "%_answer2%"=="N" goto :no2

:repeat2
goto :error2

:yes2
goto :start

:no2
echo.
echo Press a key to exit...
pause>nul
exit


Report •

#5
December 20, 2009 at 16:10:06
oh... i see there is more to be added :D sorry only read your
initial post...

Report •

#6
December 20, 2009 at 16:17:32
Oh no, dont worry about it man. This will help alot in making the batch or to any other batch that I see that needs to be made :D

Report •

#7
December 20, 2009 at 16:23:20
is this for fun? or you are going to run it in production, ie,
actually distributing to users for usage?? if you are, don't.
use a database and an interface instead. If this is just for
fun, ignore my post.

GNU win32 packages | Gawk


Report •

#8
December 20, 2009 at 16:24:30
No this is not jst for fun. Id like to be able to use this and make it easy for others to also.

And this gawk, what do I do, what do I need?


Report •

#9
December 20, 2009 at 16:28:12
i will write some...

Report •

#10
December 20, 2009 at 16:29:46
Sweet :D

Maybe I can learn from what ya put and all that since I knw what your trying to write, I knw what to look for and fix, add, edit, then enjoy


Report •

#11
December 20, 2009 at 16:51:45
I can tell you by the time you got a solution here, test it and implement it, you could have completed this already by asking your users to fill in a form.

back to the qns, if you are not doing for fun, i recommend using a database approach and using one interface to gather information. this is because, how are you going to get all these data back from the user?? go to each workstation and collect all those text files one by one??

$0.02

GNU win32 packages | Gawk


Report •

#12
December 20, 2009 at 16:56:03
lol no, this is for the users own personal use. Its for them to collect their own data. Like on family members, friends, etc.

Report •

#13
December 20, 2009 at 17:06:00
this should work like you want it... It will check if the file is already there, if there it will move it to a backup folder to keep and create a new file in the original folder with the new information. if someone edits the same contact again it will overwrite the old backup with the new backup and put in the new details in the normal folder.. with some creativity you could make a prompt for it if you'd like...

I hope this forum wont eat up the script and it stays a bit readable... otherwise you can edit it, or give me your email and i mail it...

here goes:::

@echo off
:start
cls
set /p _gender= Gender :
set /p _firstletter= First letter last name :
set /p _first= First name :
set /p _middle= Middle name :
set /p _last= Last name :

echo.
echo His/her name is: %_first% %_middle% %_last%
echo Gender: %_gender%

echo.
echo Set the date of birth.
echo.
set /p _day= Day :
set /p _month= Month :
set /p _year= Year :

echo.
echo The date of birth is: %_day% %_month% %_year%

echo.
echo Set the address.
echo.
set /p _street1= Address 1 :
set /p _street2= Address 2 :
set /p _number= Number :
set /p _postal= Postal Code :
set /p _city= City :
set /p _state= State :
set /p _country= Country :
set /p _phone= Phone :
set /p _mobile= Mobile :
set /p _email= E-mail :

echo.
echo The address is:
echo.
echo Address 1: %_street1% %_number%
echo Address 2: %_street2%
echo Postal Code: %_postal%
echo City: %_city%
echo State: %_state%
echo Country: %_country%
echo Phone: %_phone%
echo Mobile: %_mobile%
echo E-mail: %_email%

echo.
echo Would you like to write this info to a file?
echo.
echo NAME:
echo First : %_first%
echo Middle : %_middle%
echo Last : %_last%
echo.
echo DATE OF BIRTH:
echo Month : %_month%
echo Date : %_day%
echo Year : %_year%
echo.
echo GENDER:
echo Gender : %_gender%
echo.
echo CONTACT DETAILS:
echo Address 1 : %_street1% %_number%
echo Address 2 : %_street2%
echo Postal Code : %_postal%
echo City : %_city%
echo State : %_state%
echo Country : %_country%
echo Phone : %_phone%
echo Mobile : %_mobile%
echo E-mail : %_email%
echo.
set /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :error
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no

:error
echo.
echo No valid answer recieved. Try again.
echo.
set /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :repeat
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no

:repeat
goto :error

:yes
if exist
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt" md
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\BACKUP"
if exist
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
move /Y
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\BACKUP"
md
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\" 2>nul
echo NAME: >
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo First : %_first% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Middle : %_middle% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Last : %_last% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo. >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo DATE OF BIRTH: >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Month : %_month% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Date : %_day% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Year : %_year% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo. >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo GENDER: >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Gender : %_gender% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo. >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo CONTACT DETAILS: >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Address 1 : %_street1% %_number% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Address 2 : %_street2% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Postal Code : %_postal% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo City : %_city% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo State : %_state% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Country : %_country% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Phone : %_phone% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo Mobile : %_mobile% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo E-mail : %_email% >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
echo. >>
"c:\docs\%_country%\%_gender%\%_firstletter%\%_last%
%_middle% %_first%\%_first% %_middle% %_last%.txt"
goto :no

:no
echo.
echo Would you like to start a new?
echo.
set /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :error2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" goto :no2
if "%_answer2%"=="N" goto :no2

:error2
echo.
echo No valid answer recieved. Try again.
echo.
set /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :repeat2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" goto :no2
if "%_answer2%"=="N" goto :no2

:repeat2
goto :error2

:yes2
goto :start

:no2
echo.
echo Press a key to exit...
pause>nul
exit


Report •

#14
December 20, 2009 at 17:42:11
It was a little tricky sorting out those commands that made the files but I did it, everything looking great. Now to make it do something else.


Something like:


Check ADMIN rights on XP/Vista:

for /f "delims=" %%a in ('2^>^&1 ^>nul defrag -? %systemdrive%') do set notadmin=%%a
if defined notadmin (
echo Not admin!
exit /b
)

Check admin rights on WIn7:

@echo off
REM Vista
VER | FIND "Version 6.1." > nul
IF %ERRORLEVEL% == 0 (
REM Do OPENFILES to check for administrative privileges
OPENFILES > nul
IF ERRORLEVEL 1 (
COLOR CF
ECHO.Right click on this bat file and select 'Run as administrator'.
PAUSE
EXIT /B 1
)
)
pause

The check admin needs to check the OS first to make sure which part of the code it needs to check against the OP's OS.


Report •

#15
December 20, 2009 at 18:11:18
if you know these command to check for admin rights, it
wouldnt be a problem to make a batch file which
automatically finds the os it runs on :)

let the batchfile run the "ver" command to get the windows
version. write the output to a text file and read out the text file
(or to >nul) and look for a certain string.

or just prompt the user ;)
1 for XP
2 for Vista
3 for Win7


Report •

#16
December 20, 2009 at 18:42:48
wow... i truly admire your initiative! If nothing else, you will learn a lot in creating this interface. b(i/a)tch programming can be challenging. I wish you all the luck, ya alrdygot the pluck!

Report •

#17
December 20, 2009 at 18:55:32
Thnx Guys. I am fine tuning its look right now. When I am done with that Ill post it and then work on the OS admin rights thing.

Report •

#18
December 20, 2009 at 19:42:00
Okay. Here is what I modded the code to:


!HEADS UP!

When copying the below code (That is if you want to try it out) the section that actually writes the info the the text document does this weird thing and does not copy from the site right, so you MAY have to fix it by fixing the lines. So jst in case here is a pastebin link

http://pastebin.com/f1302c9e1
-----------------
BATCH
-----------------

@ECHO off
@TITLE Please provide the folling information!
@SET D1=%date:~-4,10%
@SET D2=%date:~7,-5%
@SET D3=%date:~4,-8%
:start
@ECHO.
@ECHO - Name -
@ECHO.
@SET /p _first= [First name]:
@ECHO.
@SET /p _middle= [Middle name]:
@ECHO.
@SET /p _last= [Last name]:
@CLS
@ECHO.
@ECHO - Sex -
@ECHO.
@SET /p _gender= [Sex]:
@ECHO.
@ECHO - Date of birth -
@ECHO.
@SET /p _month= [Month]:
@SET /p _day= [Day]:
@SET /p _year= [Year]:
@ECHO.
@ECHO - Other -
@SET /p _firstletter= [First letter last name]:
@CLS
@ECHO.
@ECHO SET the address. (Address 1 exp: 123 Elms Rd.)
@ECHO.
@SET /p _street1= [Address 1]:
@SET /p _street2= [Address 2]:
@SET /p _postal= [Postal Code]:
@SET /p _country= [Country]:
@SET /p _phone= [Phone]:
@SET /p _mobile= [Mobile]:
@SET /p _email= [E-mail]:
@SET /p _email2= [E-mail 2]:
@CLS
@ECHO Would you like to write this info to a file?
@ECHO.
@ECHO NAME: %_first% %_middle% %_last%
@ECHO.
@ECHO DATE OF BIRTH: %_month% %_day% %_year%
@ECHO.
@ECHO Gender : %_gender%
@ECHO.
@ECHO CONTACT DETAILS:
@ECHO Home Phone : %_phone%
@ECHO Mobile : %_mobile%
@ECHO E-mail : %_email%
@ECHO E-mail 2 : %_email2%
@ECHO %_first% %_middle% %_last%
@ECHO Address 1: %_street1%
@ECHO Address 2: %_street2%
@ECHO Postal Code: %_postal% %_city%
@ECHO State: %_state%
@ECHO Country: %_country%
@ECHO.
@SET /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :error
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no
:error
@ECHO.
@ECHO No valid answer recieved. Try again.
@ECHO.
@SET /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :repeat
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no
:repeat
goto :error
:yes
if exist "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt" md "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\BACKUP" >>NUL
if exist "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt" copy /B "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt" "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\BACKUP\%_first% %_middle% %_last%(%D3%-%D2%-%D1%).txt_%RANDOM%" >>NUL
@DEL /F /S /Q "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
md "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\ >>NUL
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO - NAME - >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO First: %_first% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Middle: %_middle% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Last: %_last% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >>"c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO - DATE OF BIRTH - >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Month: %_month% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Date: %_day% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Year: %_year% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO - GENDER - >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Sex: %_gender% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO - CONTACT DETAILS - >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Address 1: %_number% %_street1% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Address 2: %_street2% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Postal Code: %_postal% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Country: %_country% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Phone: %_phone% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Mobile: %_mobile% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO E-mail: %_email% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO E-mail 2: %_email2% >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO ---------------------------------- >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO More Options Soon To Come! >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO ---------------------------------- >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO. >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Created By: Inj3cti0ns Intel Indexer >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@ECHO Email: Inj3cti0n[@]live.com >> "c:\docs\%_country%\%_gender%\%_firstletter%\%_last% %_middle% %_first%\%_first% %_middle% %_last%.txt"
@PAUSE
goto :no
:no
@ECHO.
@ECHO Would you like to start a new?
@SET /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :error2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" Exit
if "%_answer2%"=="N" Exit
@ECHO.
@ECHO No valid answer recieved. Try again.
@ECHO.
@SET /p _answer2= Y for Yes, N for No :
if "%_answer2%"=="" goto :repeat2
if "%_answer2%"=="y" goto :yes2
if "%_answer2%"=="Y" goto :yes2
if "%_answer2%"=="n" Exit
if "%_answer2%"=="N" Exit
EXIT

--------------------
END BATCH
-------------------


There are SO many changes that it would be to much to show you them point by point. So jst look around them!

lol sorry :D


Anyways, Now I need to do that OS admin rights thing. :/


Report •

#19
December 20, 2009 at 20:10:11
just minor, save a couple steps:
IF /I "blah"=="blah"
will fold case, making "y" and "Y" equal without having to
do a discreet compare for each value, so y same as Y.

(at cmd prompt, you can see options by typing:
if /?
for /?
set /?
call /?
and see batch howto's (Judago's contribution!)


Report •

#20
December 20, 2009 at 20:37:02
So your saying I can turn this:

@SET /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :error
if "%_answer%"=="y" goto :yes
if "%_answer%"=="Y" goto :yes
if "%_answer%"=="n" goto :no
if "%_answer%"=="N" goto :no


Into this:

@SET /p _answer= Y for Yes, N for No :
if "%_answer%"=="" goto :error
IF /I "%_answer%"=="y" goto :yes
IF /I "%_answer%"=="n" goto :no


Report •

#21
December 20, 2009 at 20:41:02
Yes, It works. Thnx.


If anyone else has any suggestions, Ill be lurking this thread for a while and I WILL be back after today for check ups.


Report •

#22
December 20, 2009 at 21:30:04
to create productive programs/script, use a better language. here's your example done in Python, less code,
more readable, and using a simple database for easy retrieval of information. With its advance data types,
you can do a lot of things more easily.

import sqlite3
# database name
mydb = os.path.join("c:\\","tmp","example")

def createtable(cur,tablename="userinfo"):
    try:
        cur.execute("""create table %s (fname text, mname text, lname text, dbmth real, dbday real, dbyr real)""" %tablename)
    except Exception,e:
        print e
        return 1
    else:
        return 0

def add(cur,info,tablename="userinfo"):
    data=','.join(["'%s'" %i for i in info ])
    try:
        cur.execute("""insert into %s values( %s )""" % (tablename , data) )
    except Exception,e:
        print e
        return 1
    else:
        return 0

def datainput():
    firstname=raw_input("Enter first name: ")
    middlename=raw_input("Enter middle name: ")
    lastname=raw_input("Enter last name:")
    datemonth=raw_input("Enter DOB month: ")
    dateyear=raw_input("Enter DOB year: ")
    dateday=raw_input("Enter DOB day: ")
    # do extra checks for valid date
    return firstname,middlename,lastname,datemonth,dateyear,dateday

def view(cur,username,tablename="userinfo"):
    try:
        cur.execute("""select * from %s where lname = '%s'""" %(tablename,username))
    except Exception,e:
        print e
        return 1
    else:
        for detail in cur:
            print detail
        return 0

connection = sqlite3.connect(mydb)
c = connection.cursor()
createtable(c)
while 1:
    print """
1) Input data
2) See data
3) Exit"""
    choice=raw_input("Enter a choice: ")
    if choice=="3": break
    elif choice =="1":
        fname,mname,lname,dmth,dyr,dday=datainput()
        add(c,(fname,mname,lname,dmth,dyr,dday))
    elif choice == "2":
        lastname=raw_input("Enter last name to view details: ")
        view(c,lastname)

c.close()
connection.commit()

GNU win32 packages | Gawk


Report •

#23
December 20, 2009 at 21:36:08
I found out it was C, but other then that, that is all I know about it.


Report •

#24
December 21, 2009 at 09:48:11
silly, you ask here how to write this batch file into something
workable, i write it for you, and in the end version you place the
credits for making it to yourself ;)

Report •

#25
December 21, 2009 at 13:22:50
Oh, trust me prodigital, its not threw yet and even though my idea your hard work to give me a starting point, I am most great full.. And Idk what version you are looking at, but in the latest one it has special thanks to you, including a link to your profile here. But anyways, if yo

Report •

#26
December 21, 2009 at 14:59:34
I am stuck D:

----------------------------------

@ECHO ON
@set random=%random%
@TITLE BackUP!
@ECHO.
@ECHO What drive would you like to backup to?
@ECHO ---------------------------------------
@ECHO.
@ECHO Drives avaiable on your computer:
@fsutil fsinfo drives
@ECHO.
@Set /P _drive= BackUp Drive (leave out the "\":
@ECHO.
@Set /P _dir= Directory:
@CLS
:_doitagain2
@ECHO.
@ECHO Your about to backUp "%systemdrive%\docs\" to "%_drive%\iIndex\%_dir%"

@Set /P _yesno= Want to continue?:
@IF /I %_yesno%=="" goto _doitagain2
@IF /I %_yesno%=="y" goto _yesbu
@IF /I %_yesno%=="n" goto _doitagain
@EXIT

:_yesbu
@IF exist "%_drive%\iIndex\%_dir%" md "%_drive%\iIndex\%_dir%\BackUP_(%D3%-%D2%-%D1%_%RANDOM%)"

@IF exist "%_drive%\iIndex\%_dir%" xcopy /I /E /Q /H "%_drive%\iIndex\%_dir%\*.*" /B "%_drive%\iIndex\%_dir%_%Random%\BackUP_(%D3%-%D2%-%D1%_%RANDOM%)"
@DEL %_drive%\%_dir%\*.*

@xcopy "%systemdrive%\docs" "%_drive%\iIndex\%_dir%" /I /E /W /Q /H
@pause

@CLS
@ECHO.
@ECHO Well if everything worked just right, your docs have been backed up.
@ECHO.
@PAUSE

----------------------------------


Report •

#27
December 21, 2009 at 15:48:02
@echo off
set d1= [your variable]
set d2= [your variable]
set d3= [your variable]
set random=%random%
:start
cls
echo.
echo backup directory..
echo.
echo example path: C:\Files\My Important Data
echo.
set /p _dir=Type in the path:
if exist "%_dir%" goto :ok
goto :fail
:fail
echo.
echo %_dir%
echo.
echo does not exist.
echo.
echo Press a key to restart...
pause>nul
goto :start
:ok
md "%userprofile%\_TEMP"
xcopy "%_dir%\*" "%userprofile%\_TEMP" /E/C/Q/H/Y
md "%_dir%\Backup %d1% %d2% %d3% %random%"
xcopy "%userprofile%"\_TEMP\*" "%_dir%\Backup %d1% %d2% %d3% %random%" /E/C/Q/H/Y
rd /S/Q "%userprofile%\_TEMP"
echo.
echo Finished.
echo.
pause>nul
exit


didnt test it, so check the code... I gotta go sleep ;)

ciao


Report •

#28
December 21, 2009 at 15:56:10
mmm im a fool, could also use the xcopy and exclude the backup directory from trying to copy itself... this way you dont need to copy everything twice.

should be then:

md "%_dir%\Backup %d1% %d2% %d3% %random%"
xcopy "%_dir%\*" "%_dir%\Backup %d1% %d2% %d3% %random%" /E/C/Q/H/Y/EXCLUDE:\Backup %d1% %d2% %d3% %random%\

but im not sure if it will work... you gotta try :P


Report •

#29
December 21, 2009 at 15:59:30
anyway backing up in this manner is foolish, since there is no point in keeping data safe if you dont copy it onto at least another disk in the same system or better to a network drive.

Report •

#30
December 21, 2009 at 16:31:58
doesnt seem to work... mmm strange, ill figure it out... im not really into this xcopy stuff

Report •

#31
December 21, 2009 at 20:24:40
Meh, So far I just worked around it, this is what I have so far now.

FULL CODE:

http://pastebin.com/f65108843
---------------------------


@ECHO OFF
@SET D1=%date:~-4,10%
@SET D2=%date:~7,-5%
@SET D3=%date:~4,-8%
:_doitagain
@cls
@Title What do???
@ECHO.
@ECHO *****************************************
@ECHO Special thanks to: prodigital
@ECHO http://www.computing.net/userinfo/2...
@ECHO *****************************************
@ECHO.
@ECHO iIndex.bat
@ECHO Created By: Inj3cti0n
@ECHO.
@ECHO.
@ECHO [1] Backup Files
@ECHO.
@ECHO [2] Add Entry
@ECHO.
@SET /p _whatdo=What do???:
@IF "%_whatdo%"=="" goto _doitagain
@IF "%_whatdo%"=="1" goto _backup1
@IF "%_whatdo%"=="2" goto _iIndex
@Goto _doitagain
@EXIT
:_backup1
@CLS
@set random=%random%
@TITLE BackUP!
@ECHO.
@ECHO What drive would you like to backup to?
@ECHO ---------------------------------------
@ECHO.
@ECHO Drives avaiable on your computer:
@fsutil fsinfo drives
@ECHO.
@Set /P _drive= BackUp Drive (leave out the "\":
@CLS
@ECHO.
@ECHO.
@ECHO (Warning: Do NOT use the same dir twice.)
@ECHO.
@DIR "%_drive%\iIndex\"
@Set /P _dir= Directory:
@CLS
@ECHO.
@ECHO Your about to backUp "%systemdrive%\iIndex\docs\" to "%_drive%\iIndex\%_dir%"
@xcopy "%systemdrive%\docs" "%_drive%\iIndex\%_dir%" /I /E /W /Q /H
@CLS
@ECHO.
@MSG * DONE! - "%_drive%\iIndex\%_dir%"
@ECHO.
@goto :_doitagain


Report •

#32
December 23, 2009 at 14:52:52
Yes, that works, but I thought the original idea was to make the backup in the same folder (this is what is causing problems with xcopy) so I thought to copy the folder to elsewhere, and copy it back after. But this also didnt work...

I have a nice one for you also :P If you like batch files.......
But watch out with this one if you need certain windows updates to be removed again, because this batchfile will remove all downloaded windows updates, just not the Service Pack ones...

Please do check the file if you want to run it so you wont run into complications with your OS or other software... oh yes, and... there is a folder on my drive called "Onlangs Geopend" this is the folder containing Recently opened files... I dont know the english name for it out of my head :S...

http://pastebin.com/m5710ff30
---
Cleanitall.bat
---


Report •

#33
December 23, 2009 at 16:31:45
This will create a backup in the original folder. Just it does not copy the directory structure, but instead copy all files in all directories to a single backup folder overwriting duplicates. BUT in the same folder. Pretty useless :C...

but anyway, maybe youll find some use...

http://pastebin.com/f4db7bb9f


Report •


Ask Question