『楼 主』:
[原创]********大小写转换********
@echo off
::::::::Letter Style {s11ss 2007-11-4}::::::::
::Idea:Use the "if /i" command to compare a letter whith another,then construct the new string.
::Get arguments:
::Judge if 2 arguments are inputed:
if "%2" equ "" goto :h
set f=%1
set f=%f:~-1%
set str=%2
set ns=
set r=::
set/a n=0
if /i "%f%" equ "m" (
::The first letter will be in the small style:
set f=s
::If -m is selected,then make the sentence 1 executable,which is started by %r%:
set r=
) else (
::Check if the first argument is available:
if /i not "%f%" equ "s" (if /i not "%f%" equ "b" (goto :h))
)
::Create the new string by letter(one by one):
:c
call set o=%%str:~%n%,1%%
if not "%o%" equ "" (
call :%f% %o%
set/a n+=1
REM the sentence 1:
%r%if %f% equ b (set f=s) else (set f=b)
goto :c
)
::Output the result:
echo %ns%
goto :eof
::Functions:
::big 2 small:
:s
set s=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
call :o
goto :eof
::small 2 big:
:b
set s=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
call :o
goto :eof
::create the result:
:o
for %%a in (%s%) do (
if /i "%o%" equ "%%a" (
set ns=%ns%%%a
goto :eof
)
)
::If it is not a letter,%o% won't be changed:
set ns=%ns%%o%
goto :eof
::help:
:h
echo.Two Arguments:
echo.1.-b(small2big)/-s(big2small)/-m(mixed)
echo.2.a string
echo.
echo.e.g.:
echo.%0 -m www.cn-dos.net
|