中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-15 12:59
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » Convert lowercase letters to uppercase
Printable Version  4,547 / 12
Floor1 namejm Posted 2007-01-17 07:01
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Lowercase letters to uppercase can be solved by listing methods like set str=%str:a=A%, set str=%str:b=B%..., but this is purely manual work with no skill involved. The following demo code allows you to no longer do the repetitive labor of copy + paste + modify that is unfun when converting lowercase letters to uppercase:
Floor2 tao0610 Posted 2007-01-17 07:08
高级用户 Posts 218 Credits 579
Not bad, but still used to converting with Ultraedit.
Floor3 zh159 Posted 2007-01-17 09:53
金牌会员 Posts 1,467 Credits 3,687
It seems it doesn't need to be so complicated, just a single for can handle it:


Just change it a bit to (a b c d e f g h i j k l m n o p q r s t u v w x y z) and it's okay

[ Last edited by zh159 on 2007-1-16 at 08:54 PM ]
Floor4 namejm Posted 2007-01-17 09:59
荣誉版主 Posts 1,737 Credits 5,226 From 成都
The third floor made full use of the feature that replacement statements are case-insensitive, which is clever.
Floor5 redtek Posted 2007-01-17 10:07
金牌会员 Posts 1,147 Credits 2,902
The solutions for the codes in the 1st floor and the 3rd floor are so wonderful~ : ) ) )

[ Last edited by redtek on 2007-1-16 at 09:08 PM ]
Floor6 tashaxin Posted 2007-01-20 08:20
初级用户 Posts 30 Credits 99
Floor7 greenworld Posted 2007-09-15 21:48
初级用户 Posts 45 Credits 86
Thanks to LZ and the boss on the 3rd floor, it's amazing, I've learned...
Floor8 106942397 Posted 2008-05-11 17:10
初级用户 Posts 15 Credits 29
Why make it so complicated for no reason?

setlocal ENABLEDELAYEDEXPANSION

set /p str=Please enter the string (press Enter directly to exit):
for /l %%l in (0,1,100) do (
call set s%%l=!str:~%%l,1!
set Q=!s%%l!
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if /i !Q!==%%i set/p=%%i<nul
)
if "!Q!"=="" goto :Q1
)
:Q1
ECHO\
%0
Is this okay?

[ Last edited by 106942397 on 2008-5-11 at 09:29 PM ]
Floor9 26933062 Posted 2008-05-11 17:33
银牌会员 Posts 879 Credits 2,268
Hehe, 8th floor. Please input abcd and then run your code and compare the results with the code on the 3rd floor. Besides, is the code on the 3rd floor more complicated than yours?
Floor10 106942397 Posted 2008-05-11 21:24
初级用户 Posts 15 Credits 29
Case Conversion

setlocal ENABLEDELAYEDEXPANSION

set /p str=Please enter the string (press Enter directly to exit):
for /l %%l in (0,1,100) do (
call set s%%l=!str:~%%l,1!
set Q=!s%%l!
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
for %%k in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if !Q!==%%i if /i !Q!==%%k set/p=%%k<nul
if !Q!==%%k if /i !Q!==%%i set/p=%%i<nul

))
if "!Q!"=="" goto :Q1
)
:q1
echo\
%0

[ Last edited by 106942397 on 2008-5-11 at 09:30 PM ]
Floor11 olslyang Posted 2008-06-20 22:36
新手上路 Posts 2 Credits 4 From 河北保定
Boss, I can't understand the part that's listed. Can you explain it? I don't understand the usage of that replacement statement!
I can't understand the part str=%%str:%%i=%%i%%. Is there any expert to give me some pointers!
My QQ 362998909
Floor12 olslyang Posted 2008-06-20 22:36
新手上路 Posts 2 Credits 4 From 河北保定
Boss, I can't understand the place listed. Can you explain it! I don't understand the usage of that replacement statement!
I can't understand the part str=%%str:%%i=%%i%%. Is there any expert to give some guidance!
My QQ 362998909
Floor13 moniuming Posted 2008-06-20 23:08
银牌会员 Posts 574 Credits 1,335 From 广西
Originally posted by olslyang at 2008-6-20 22:36:
Boss, I can't understand the part that lists things. Can you explain it to me! I don't understand the usage of that replacement statement!
I can't understand the part "str=%%str:%%i=%%i%%". Is there any expert to give some guidance!
My QQ 362998909


"Variable delay"
Maybe this can be understood:
call set str=%%str:%%i=%%i%%
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023