[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
为什么用不能用code括起来 正解看 15楼

[ 本帖最后由 skuny 于 2009-1-19 11:17 编辑 ]

TOP

回复 16楼 的帖子

Q: 如何用code把代码扩起来?
A: http://bbs.bathome.net/thread-404-1-1.html
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 17楼 的帖子

括起来后重新编辑出现乱码!!
  1. @ECHO OFF&setlocal enabledelayedexpansion
  2. :222
  3. set st=
  4. set /p "strr=请输入字符串:"
  5. echo 转换前!strr!
  6. call :111 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
  7. echo 转换后:!st!
  8. pause>nul&goto :222
  9. :111
  10. for /l %%a in (0,1,100) do (
  11.   set "stt=!strr:~%%a,1!"
  12.   if not defined stt goto :eof
  13.   set /a aaa=0
  14.     for %%i in (%*) do (
  15.     set /a aaa+=1
  16.     if /i "!stt!"=="%%i" (
  17.          if not "!stt!"=="%%i" set "st=!st!%%i"&set /a aaa=0
  18.          if "!stt!"=="%%i" (
  19.              set "bb=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"
  20.              for %%k in (!bb!) do if /i "!stt!"=="%%k" set "st=!st!%%k"&set /a aaa=0
  21.                    )
  22.                )
  23.     if !aaa!==26 set "st=!st!!stt!"
  24.         )                    
  25. )
复制代码

TOP

回复 18楼 的帖子

  1. @ECHO OFF&setlocal enabledelayedexpansion
  2. :222
  3. set st=
  4. set /p "strr=请输入字符串:"
  5. echo 转换前!strr!
  6. call :111 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
  7. echo 转换后:!st!
  8. pause>nul&goto :222
  9. :111
  10. for /l %%a in (0,1,100) do (
  11.   set "stt=!strr:~%%a,1!"
  12.   if not defined stt goto :eof
  13.   set /a aaa=0
  14.     for %%i in (%*) do (
  15.     set /a aaa+=1
  16.     if /i "!stt!"=="%%i" (
  17.          if not "!stt!"=="%%i" set "st=!st!%%i"&set /a aaa=0
  18.          if "!stt!"=="%%i" (
  19.              set "bb=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"
  20.              for %%k in (!bb!) do if /i "!stt!"=="%%k" set "st=!st!%%k"&set /a aaa=0
  21.                    )
  22.                )
  23.     if !aaa!==26 set "st=!st!!stt!"
  24.         )                    
  25. )
复制代码

TOP

  1. @echo off&setlocal enabledelayedexpansion
  2. set "var=abHJ      dfsKHK    aB"&echo !var!
  3. for /f "delims=  tokens=1-3" %%i in ("%var%") do (
  4. set "x=%%i%%j%%k"
  5. set "x=!x:abHJ=ABhj!"
  6. set "x=!x:dfsKHK=DFSkhk!"
  7. set "x=!x: aB= Ab!"
  8. echo !x!
  9. )
  10. pause>nul
复制代码

TOP

LS错
大小写互换,对象不是确定的
不只是适合自己给定的一段字符

TOP

回复 10楼 的帖子

在学习的时候不明白这一段set !var:~0,1!=%%i起到什么作用
还有经常看到set Res=!Res!!T2!这样的语句,就是后面的这个!T2!是什么意思

TOP

回复 1楼 的帖子

@echo off
echo. 大小写字母转换--Uppercase-reChange-Lowercase-----------

set small=a b c d e f g h i j k l m o p q r s t u v w x y z
set big=A B C D E F G H I J K L M N O P Q R S T U V W S Y Z
set tt=abHJ   dfsKHK      aB
rem 以上是原始字符可以改为命令输入set /p tt=
echo  转换前的字符:%tt%
setlocal enabledelayedexpansion
ne
set tt1=!tt:~-1!
set tt2=!tt:~0,-1!
set tt=!tt1!+!tt2!
if  !tt:~-1! neq + (goto:one) else (set tt=!tt:+=,!&echo 插入逗号后:!tt!)

:a
for  %%i in (!small!) do (
    for %%j in (!tt!) do (
    if %%i==%%j (set sml=!sml!%%j )
    )
)

:b
for %%i in (!big!) do (
    for %%j in (!tt!) do (
    if %%i==%%j (set bg=!bg!%%j )
    )
)

:end
echo 原始字符里面的小写字母:!sml!
echo 原始字符里面的大写字母:!bg!

for %%1 in (!big!) do (
    for %%2 in (!sml!) do (
    if /i %%1==%%2 (set tt=!tt:%%2=%%1! )
    )
)
echo 把原始字符里的小写转换成大写:!tt!

for %%1 in (!small!) do (
    for %%2 in (!bg!) do (
    if /i %%1==%%2 (set tt=!tt:%%2=%%1! &echo !tt!)
    )
)
set tt=!tt:,=!
echo  转换后的字符:!tt!-成功.ok!

[ 本帖最后由 myzwd 于 2009-2-26 13:52 编辑 ]
1

评分人数

TOP

回复 22楼 的帖子

在教学区搜索“变量延迟扩展”

Q: 如何使用论坛的搜索功能来解决自己的问题?
A: 参考:http://bbs.bathome.net/thread-3473-1-1.html
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. set Lcase= abcdefghijklmnopqrstuvwxyz
  4. set Ucase= ABCDEFGHIJKLMNOPQRSTUVWXYZ
  5. for /l %%a in (1,1,26) do set _!Lcase:~%%a,1!=%%a
  6. set /p var=请输入:
  7. :loop
  8. set char=!var:~%pi%,1!
  9. set /a sn=_!char! 2>nul||set sn=0
  10. if defined char (
  11. if %sn% gtr 0 (
  12.     if "!char!"=="!Lcase:~%sn%,1!" (set str=!str!!Ucase:~%sn%,1!) else (set str=!str!!Lcase:~%sn%,1!)
  13. ) else (
  14.     set str=!str!!char!
  15. )
  16. set /a pi+=1
  17. goto loop
  18. )
  19. echo.!str!
  20. echo.&pause
复制代码
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

回复 1楼 的帖子-

@echo off
cls
echo -----大小写转换--不能输入同时含有象m和M这类字符--
set small=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
set big=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
set /p char=
setlocal enabledelayedexpansion


:start
set charend=!char:~-1!
set chardel=!char:~,-1!
set char=!charend!+!chardel!
if !char:~-1! neq + (goto start) else (set char=!char:+=!)
echo 字符状态: !char!

:sml
for %%i in (!small!) do (
    for %%j in (!char!) do (
       if %%i == %%j (set sml=!sml! %%j)
    )  
)
echo sml集合: !sml!

:bg
for %%i in (!big!) do (
    for %%j in (!char!) do (
       if %%i == %%j (set bg=!bg!%%j )
    )  
)
echo bg集合: !bg!

:small
set charend=!char:~,1!
for %%i in (!sml!) do (
  if !charend! == %%i (
     for %%j in (!big!) do (
         if /i %%j == !charend! (set charend=%%j)
     )
  )
)
:big
for %%i in (!bg!) do (
  if !charend! == %%i (
     for %%j in (!small!) do (
         if /i %%j == !charend! (set charend=%%j)
     )
  )
)

set chardel=!char:~1!
set char=!chardel!+!charend!
if  !charend! neq +  (goto small)
set char=!char:+=!
echo 新字符状态:!char!

如果有一个字母大小写都含有时,没法转换,这改怎么办?

TOP

回复 26楼 的帖子

那就说明你的方法还不够好,继续改进。
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

回复 5楼 的帖子

  1. 要是改为
  2. pause
  3. mode con cp select=936
  4. cls
  5. exit /b
  6. 就完美了
复制代码

[ 本帖最后由 myzwd 于 2009-2-27 23:05 编辑 ]

TOP

  1. @echo off
  2. set /p var=please input:
  3. :start
  4. set "lstr=abcdefghijklmnopqrstuvwxyz"
  5. set "ustr=ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  6. set vr=%var:~0,1%
  7. :loop
  8. set ls=%lstr:~0,1%
  9. set %ls%=%ustr:~0,1%
  10. if "%vr%"=="%ls%" call,set /p=%%%ls%%%<nul&goto next
  11. set us=%ustr:~0,1%
  12. set %us%=%lstr:~0,1%
  13. if "%vr%"=="%us%" call,set /p=%%%us%%%<nul&goto next
  14. set lstr=%lstr:~1%
  15. set ustr=%ustr:~1%
  16. if "%ustr%"=="" set /p= <nul&goto next
  17. goto loop
  18. :next
  19. set var=%var:~1%
  20. if "%var%"=="" goto end
  21. goto start
  22. :end
  23. echo.
  24. pause
复制代码

[ 本帖最后由 keen 于 2009-4-2 13:17 编辑 ]
(*^_^*)

TOP

@echo off&setlocal enabledelayedexpansion
set /p "string=请输入字符串:"
set "code=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 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"
set string=!string: =#!

请问在这段代码中: set /p "string=请输入字符串:" 和set /p string=请输入字符串:    有什么区别?
另外"set string=!string: =#!“是变量扩展吗?他是什么含意
谢谢

TOP

返回列表