Windows Vista Beta | WinVistaBeta.com - Message | syntax for batch file

July 03, 2008  
Subject: syntax for batch file
Group: microsoft.public.windows.vista.file_management
Date: 5/4/2008 4:23:01 AM
From: "geotso" [Email Address Protection]

I hope this is the right ng to post my question. If not, please redirect me
accordingly!

Well,
I have a myDir.bat file with just one line, like this:
dir %1:\%2

which works fine, when I type in a cmd window something like this:
myDir E *.mp3

However, sometimes I forget to add the two parameters, so I get an error
"... syntax is incorrect".
So, can you please tell me, how to make it check if the parameters are
there, and prompt me to write them down if they're not?

Furthermore, how to make it ask me if I want to use some switches of the dir
command (e.g. /a/s and/or /o/b/p etc.)?

--
Please remove hyphens to contact me
----- --- -- -- -
geotso
----- --- -- -- -


Back
Subject: Re: syntax for batch file
Group: microsoft.public.windows.vista.file_management
Date: 5/4/2008 6:40:55 PM
From: "Chirag" [Email Address Protection]

For the first part, the following batch file should do fine:

---
@echo off
if "%1"=="" (
echo "Invalid arguments. Usage: myDir <drive> <filter>"
exit /b 1
)
if "%2"=="" (
echo "Invalid arguments. Usage: myDir <drive> <filter>"
exit /b 2
)
dir %1:%2
---

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"geotso" <ge-o-tso@hotmail.com> wrote in message
news:82A17718-ED26-42DA-A117-5B359D9DD186@microsoft.com...
>I hope this is the right ng to post my question. If not, please redirect me
>accordingly!
>
> Well,
> I have a myDir.bat file with just one line, like this:
> dir %1:\%2
>
> which works fine, when I type in a cmd window something like this:
> myDir E *.mp3
>
> However, sometimes I forget to add the two parameters, so I get an error
> "... syntax is incorrect".
> So, can you please tell me, how to make it check if the parameters are
> there, and prompt me to write them down if they're not?
>
> Furthermore, how to make it ask me if I want to use some switches of the
> dir command (e.g. /a/s and/or /o/b/p etc.)?
>
> --
> Please remove hyphens to contact me
> ----- --- -- -- -
> geotso
> ----- --- -- -- -


Back