.


:




:

































 

 

 

 





If

.

if [ not ] errorlevel [ else ]

if [ not ] 1 == 2 [ else ]

if [ not ] exist _ [ else ]

not - .

errorlevel - , , Cmd.exe, , .

- , .

1 == 2 - , 1 2 . (, %1). .

exist _ - , _.

_ - . _.

EQU
NEQ
LSS
LEQ
GTR
GEQ

, :

if [ /i ] 1 _ 2 [ else ]

if cmdextversion [ else ]

if defined [ else ]

/i - . /i string1 == string2 if. . 1, 2 , .

cmdextversion - , , Cmd.exe, . 1. 1 . cmdextversion , ( ).

defined - , .

- else.

 

, if, , , . , , if, , else, .

, . errorlevel .

defined

defined : %errorlevel%, %cmdcmdline% %cmdextversion%.

%errorlevel% errorlevel, ERRORLEVEL. .

errorlevel :

goto answer%errorlevel%
:answer0
echo 0
:answer1
echo 1
goto end
:end
echo !

_ :

if %errorlevel% LEQ 1 goto okay

%cmdcmdline% , Cmd.exe, Cmd.exe, cmdcmdline. cmdcmdline.

%cmdextversion% cmdextversion, CMDEXTVERSION. .

else

else , if.

, :

IF EXIST _. (del _.) ELSE echo _.

Product.dat , :

if not exist product.dat echo

if , (NUL). , , . :

if exist c:mydir\nul goto process

if echo : :

if exist *.rpt echo .

 

For

.

for { % | %% } in ( ) do [ ]

{ % | %% } - . . % for . %% for . , , %A, %B %C.

( ) - . , , , . .

- . , , , ( ).

- , .

 

for

for .

for.

for %% ( %% ) , .

for , 52 .

, 09, %0 %9. , %%f.

. (* ?). :

(*.doc)

(*.doc *.txt *.me)

(jan*.doc jan*.rpt feb*.doc feb*.rpt)

(ar??1991.* ap??1991.*)

for, %% ( % ), . , ( ), .

in do

In do , for. - , .

for

( ), for.

(* ?), , , ( ), . .

for /D { %% | % } in ( ) do [ ]

[ : ] , for . /R , . (.), . .

for /R [[ : ] ] { %% | % } in ( ) do [ ]

for .

 

2.1. . Lab2.

2.2. , copy (Far, Total Commander). , .bat .cmd, My.bat. , :

echo off
echo.
echo
echo
echo echo
echo.

2.3. - Ctrl+Z.

2.4. , .

2.5. rem, pause, goto . A . , pause , . . goto begin . CTRL+C Y. , :

@echo off

rem It is comment!
:begin
copy a:*.*
echo Please put a new disk into drive A
pause
goto begin

2.6. . . , , - -. , Folder1 Folder2, %1 Folder1, %2 Folder2. :

xcopy %1\*.* %2

 

2.7. my3.cmd, :

my3.cmd C:\folder1 D:\folder2

, :

xcopy C:\folder1 \*.* D:\folder2

, , .

2.8. shift, if .

Mycopy.bat , shift . . . todir.

MYCOPY.BAT . :mycopy 1 2...

 

:@echo offset todir=%1:getfileshiftif "%1"=="" goto endcopy %1 %todir%goto getfile:endset todir=echo EXIT!

 

shift /n, n- , n . shift /2 todir. :

@echo on:getfileif "%2"=="" goto endcopy %2 %1shift /2goto getfile:endecho EXIT!




:


: 2016-11-02; !; : 1038 |


:

:

, .
==> ...

1789 - | 1697 -


© 2015-2024 lektsii.org - -

: 0.027 .