*NIX getopt alike for DOS
up vote
0
down vote
favorite
I want to write a DOS script with multiple optional option flags. I have to parse these optional options.
An example:
get_resolution.bat /?
get_resolution.bat /h input.jpg
get_resoltion.bat /v input.jpg
Under *NIX this can be done with getopts.
The same examples under *nix:
get_resolution -?
get_resolution -h input.jpg
get_resolution -v input.jpg
In the *nix script txt file get_resolution
one would then write:
while getopts ?hv flag
do
case $flag in
?) man get_resolution
h) get_horizontal_resolution $1
v) get_vertical_resolution $1 ;;
esac
done
Does there exist a DOS equivalent for the *nix getopts?
windows-10 batch ms-dos
add a comment |
up vote
0
down vote
favorite
I want to write a DOS script with multiple optional option flags. I have to parse these optional options.
An example:
get_resolution.bat /?
get_resolution.bat /h input.jpg
get_resoltion.bat /v input.jpg
Under *NIX this can be done with getopts.
The same examples under *nix:
get_resolution -?
get_resolution -h input.jpg
get_resolution -v input.jpg
In the *nix script txt file get_resolution
one would then write:
while getopts ?hv flag
do
case $flag in
?) man get_resolution
h) get_horizontal_resolution $1
v) get_vertical_resolution $1 ;;
esac
done
Does there exist a DOS equivalent for the *nix getopts?
windows-10 batch ms-dos
2
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to write a DOS script with multiple optional option flags. I have to parse these optional options.
An example:
get_resolution.bat /?
get_resolution.bat /h input.jpg
get_resoltion.bat /v input.jpg
Under *NIX this can be done with getopts.
The same examples under *nix:
get_resolution -?
get_resolution -h input.jpg
get_resolution -v input.jpg
In the *nix script txt file get_resolution
one would then write:
while getopts ?hv flag
do
case $flag in
?) man get_resolution
h) get_horizontal_resolution $1
v) get_vertical_resolution $1 ;;
esac
done
Does there exist a DOS equivalent for the *nix getopts?
windows-10 batch ms-dos
I want to write a DOS script with multiple optional option flags. I have to parse these optional options.
An example:
get_resolution.bat /?
get_resolution.bat /h input.jpg
get_resoltion.bat /v input.jpg
Under *NIX this can be done with getopts.
The same examples under *nix:
get_resolution -?
get_resolution -h input.jpg
get_resolution -v input.jpg
In the *nix script txt file get_resolution
one would then write:
while getopts ?hv flag
do
case $flag in
?) man get_resolution
h) get_horizontal_resolution $1
v) get_vertical_resolution $1 ;;
esac
done
Does there exist a DOS equivalent for the *nix getopts?
windows-10 batch ms-dos
windows-10 batch ms-dos
edited Nov 17 at 19:38
asked Nov 17 at 18:27
Francky Leyn
324
324
2
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45
add a comment |
2
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45
2
2
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
In batch scripts all arguments are stored in variable %*
. Each argument can accessed by variable %1 for the first argument, and %2 for the second and so on. You can handle the arguments like this until %9.
More elegant argument handling requires the use of shift-command.
Take a look this Stackoverflow question: https://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-windows-command-line
It has more information about handling arguments in batch scripts.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
In batch scripts all arguments are stored in variable %*
. Each argument can accessed by variable %1 for the first argument, and %2 for the second and so on. You can handle the arguments like this until %9.
More elegant argument handling requires the use of shift-command.
Take a look this Stackoverflow question: https://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-windows-command-line
It has more information about handling arguments in batch scripts.
add a comment |
up vote
1
down vote
In batch scripts all arguments are stored in variable %*
. Each argument can accessed by variable %1 for the first argument, and %2 for the second and so on. You can handle the arguments like this until %9.
More elegant argument handling requires the use of shift-command.
Take a look this Stackoverflow question: https://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-windows-command-line
It has more information about handling arguments in batch scripts.
add a comment |
up vote
1
down vote
up vote
1
down vote
In batch scripts all arguments are stored in variable %*
. Each argument can accessed by variable %1 for the first argument, and %2 for the second and so on. You can handle the arguments like this until %9.
More elegant argument handling requires the use of shift-command.
Take a look this Stackoverflow question: https://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-windows-command-line
It has more information about handling arguments in batch scripts.
In batch scripts all arguments are stored in variable %*
. Each argument can accessed by variable %1 for the first argument, and %2 for the second and so on. You can handle the arguments like this until %9.
More elegant argument handling requires the use of shift-command.
Take a look this Stackoverflow question: https://stackoverflow.com/questions/14286457/using-parameters-in-batch-files-at-windows-command-line
It has more information about handling arguments in batch scripts.
edited Nov 17 at 20:10
answered Nov 17 at 19:51
Aulis Ronkainen
6151514
6151514
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1376284%2fnix-getopt-alike-for-dos%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
You’re most certainly not talking about DOS. Please read the tag descriptions carefully and edit your question accordingly.
– Daniel B
Nov 17 at 18:45