Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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,
2009
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: www.cnn.com,
www.weather.com, or www.msn.com. I want to
launch the browser on the choice chosen.This is what I have written so far:
echo off:menu
cls
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
cls
goto menu:first
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
pause
goto menu:second
:third
:forth
echo 1. www.cnn.com
echo 2. www. weather.com
echo 3. www.msn.com
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 www.cnn.com
if '%choice%'=='2' start www.weather.com
if '%choice%'=='3' start www.msn.com
if '%choice%'=='4' goto menu
cls
goto forth:fith
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
cls
goto fith:end
/pre>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.

love2,
Try this and let us know:
Change these lines:
:first
set choice=
set /p choice= %date:~-10,-8% please type
the 2 digit number seen:
if '%choice%'=='01' echo today is Januaryto
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.
--
Holla.

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!

ya I think I figured out the date thing I changed it to
:first
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 %%ithis 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

love2,
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.
:NoDir
echo Dir %dir2clear% does not exist.For part 3,
the above and use attrib command.
type "attrib /?" to get help on attrib.--
Holla.

![]() |
Perl script help
|
batch file if help
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |