@echo off
::color 1
rem echo usege
echo hello word!
echo.off
echo.
echo.on
rem set 用法
set ver=abc
echo %ver%
::reset the ver
set ver=
set ver_1=def
set ver_2=%ver%
echo %ver_1%
::set /a 数值表达式
set /a a1=1,a2=2
set /a res=a1 + a2
echo res=%res%
set /a result=%res%
echo result=%a1%+%a2%=%result%
if %a1%==%a2% (
echo a1 is equal to a2
) else (
echo a1 is not equal to a2
)
if %errorlevel%==0 (
echo success!
) else (
echo failed!
)
if errorlevel 1 (
echo success 1 !
) else (
echo failed 1 !
)
if exist C:\meng_F\DOCmdStudy\test.txt (
echo file is find
del C:\meng_F\DOCmdStudy\test.txt
) else (
echo file is not find !
)
if defined a1 (
echo a1 have define
) else (
echo a1 no define
)
::set /p 变量名=值 等号不要加空格
::set /p info=input:
::echo your input info : %info%
::/I distinguish the A and a
set test1=123
set test2=abc
set test3=12
if /I %test2% equ ABC (
if %test1% geq %test3% (
echo %test1%^>=%test3%
) else (
echo test1^<test3
)
) else (
echo %test2% not equal ABC!
)
::set local enableDelayExpansion
echo eg_1
set local_test=apple
if %local_test%==apple (
set local_test=orange
if %local_test%==orange (
echo reset veriable successful [%local_test%]
) else (
echo reset veriable failed [%local_test%]
)
)
echo %local_test%
echo eg_2
setlocal enableDelayedExpansion
set local_test_1=apple1
if %local_test_1%==apple1 (
set local_test_1=orange1
if "!local_test_1!" == "orange1" (
echo reset successful [!local_test_1!]
) else (
echo reset failed [!local_test_1!]
)
)
echo %local_test_1%
endlocal
::for
echo eg_1
for %%i in (1,3,5,7) do echo %%i
echo eg_2
for %%i in (1,*) do (
echo %%i
)
echo eg_3
cd C:\meng_F\DOCmdStudy
echo file:
for %%f in (*) do (
echo %%f
)
echo folder:
for /d %%d in (*) do (
echo %%d
)
echo eg_4
echo file:
for /r C:\meng_F\DOCmdStudy %%f in (*) do (
echo %%f
)
echo folder:
for /d /r C:\meng_F\DOCmdStudy %%d in (*) do (
echo %%d
)
rem 设置标题的内容
title nick test
pause > nul
|