Need batch that does 5 things

March 15, 2009 at 15:46:09
Specs: Windows Vista
Hi, I need a batch file that 1. gives me a menu
with choices to:
1. print todays date
2. clear files
3. clear archive
4. get news
5. exit
for choice 1 i want the output to be the name
of the month not the numerical value so
something like today is Tuesday march 15,
for choice 2 I want it to ask the user what
directory to clear and provide a prompt saying
are you sure? before deleting files.
for choice 3 I want to be able to clear the
archive attribute from all files in a given
directory. I want to be prompted for which
directory to act on.
for choice 4 I want it to display a secondary
menu that selects from:,, or I want to
launch the browser on the choice chosen.

This is what I have written so far:

echo off

if '%1%'=='' ( echo 1. print today's date )
if '%2%'=='' ( echo 2. clear files )
if '%3%'=='' ( echo 3. clear archive )
if '%4%'=='' ( echo 4. get news )
echo 5. Exit
set choice=
set /p choice="Please select a number ( 1-5 )
and press enter: "

if '%choice%'=='' goto menu
if '%choice%'=='1' goto first
if '%choice%'=='2' goto second
if '%choice%'=='3' goto third
if '%choice%'=='4' goto forth
if '%choice%'=='5' goto fith
goto menu

set choice=
set /p choice= %date:~-10,-8% please type
the 2 digit number seen:
if '%choice%'=='01' echo today is January
if '%choice%'=='02' echo today is Febuary
if '%choice%'=='03' echo today is March
if '%choice%'=='04' echo today is April
if '%choice%'=='05' echo today is May
if '%choice%'=='06' echo today is June
if '%choice%'=='07' echo today is July
if '%choice%'=='08' echo today is August
if '%choice%'=='09' echo today is September
if '%choice%'=='10' echo today is October
if '%choice%'=='11' echo today is November
if '%choice%'=='12' echo today is December
date /t
goto menu



echo 1.
echo 2. www.
echo 3.
echo 4. Exit to menu
set choice=
set /p choice="Select where to get your news
from (1-3): "

if '%choice%'=='' goto forth
if '%choice%'=='1' start
if '%choice%'=='2' start
if '%choice%'=='3' start
if '%choice%'=='4' goto menu
goto forth

set choice=
set /p choice="Are you sure you want to exit?
y/n: "

if '%choice%'=='' goto fith
if '%choice%'=='y' goto end
if '%choice%'=='n' goto menu
goto fith


the date thing for section 1 doesn't work and
i'm not really sure how to get it to same for
section 2 and 3 if anyone has any idea how to
do it it would be greatly appreciated. Thanks.

See More: Need batch that does 5 things

Report •

March 16, 2009 at 02:01:44

Try this and let us know:
Change these lines:
set choice=
set /p choice= %date:~-10,-8% please type
the 2 digit number seen:
if '%choice%'=='01' echo today is January


set choice=
set choice=%date:~-10,-8%
if "%choice%"=="01" echo today is January

:and so on for other months.. that is to remove single quotes and replace it by double quotes.


Report •

March 16, 2009 at 07:20:08
ok but for the date section I dont want to be prompted to get the month name I would like it to just do it. If thats possible? Let me know if you know how to do that or the rest. Thanks!

Report •

March 16, 2009 at 09:13:55

1. Have you tried what I suggested?
2. Does it prompt for the month number?


Report •

Related Solutions

March 16, 2009 at 11:03:58
ya I think I figured out the date thing I changed it to

set month= % date:~-10,-8%
for /f "eol=; tokens=%month% delims=," %%i in ("January,Febuary,March,April,May,June,July,August,September,October,November,December") do set month %%i && echo %%i

this gives me the output in month so March instead of 03

I still need help on part 2 and 3 though if you have any ideas

Report •

March 17, 2009 at 10:44:51
for part 2,
set /p dir2clear=What dir?
set /p Confirm=Are u sure to delete %dir2clear%
if not exist %dir2clear% goto :NoDir
cd %dir2clear%
:well, you know the rest.
echo Dir %dir2clear% does not exist.

For part 3,
the above and use attrib command.
type "attrib /?" to get help on attrib.


Report •

March 17, 2009 at 13:03:08
Ok thanks got everything working perfectly now!

Report •

Ask Question