China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 03:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: how to make IF ignore case when comparing View 856 Replies 2
Original Poster Posted 2008-06-20 10:56 ·  中国 江苏 苏州 吴中区 电信
初级用户
Credits 44
Posts 18
Joined 2008-03-30 13:48
18-year member
UID 114439
Gender Male
Status Offline
rt
How do I make a case-insensitive comparison in if

One of my batch files needs parameters, and the parameters need to ignore case, for example
-help and -HELP and -heLP etc. should all have the same effect
I don't want to write it like this
iif "%1"=="-help" goto help
if "%1"=="/help" goto help
if "%1"=="-HELP" goto help
if "%1"=="/HELP" goto help

[ Last edited by tt518 on 2008-6-20 at 11:04 AM ]
Floor 2 Posted 2008-06-20 11:12 ·  中国 北京 联通
社区乞丐
Credits -61
Posts 37
Joined 2008-04-19 17:10
18-year member
UID 116329
Gender Male
Status Offline
I suggest the OP read the help more before asking questions


/I switch; if this switch is specified, it means that the string comparison
to be performed is case-insensitive.
/I can be used with IF in the string1==string2 form. These
comparisons are generic; the reason is that if string1 and string2 are both made up of numbers,
the strings will be converted to numbers and compared numerically.
Floor 3 Posted 2008-06-20 11:14 ·  中国 江苏 苏州 吴中区 电信
初级用户
Credits 44
Posts 18
Joined 2008-03-30 13:48
18-year member
UID 114439
Gender Male
Status Offline
Ah, thank you very much!!! I'm a newbie, please look after me, everyone!
Forum Jump: