syntax for batch file

  • Thread starter Thread starter geotso
  • Start date Start date
G

geotso

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.)?
 
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
 
Back
Top