Chr*_*s J 711
if exist <insert file name here> (
rem file exists
) else (
rem file doesn't exist
)
Run Code Online (Sandbox Code Playgroud)
或者在一行上(如果只需要执行一个操作):
if exist <insert file name here> <action>
Run Code Online (Sandbox Code Playgroud)
例如,如果文件存在,这将在autoexec.bat上打开记事本:
if exist c:\autoexec.bat notepad c:\autoexec.bat
Run Code Online (Sandbox Code Playgroud)
She*_* 蒋晟 81
C:\>help if
Run Code Online (Sandbox Code Playgroud)
在批处理程序中执行条件处理.
IF [NOT] ERRORLEVEL数字命令
IF [NOT] string1 == string2命令
IF [NOT] EXIST filename命令
RBe*_*eig 35
尝试类似以下示例,引自IF /?Windows XP 的输出:
IF EXIST filename. (
del filename.
) ELSE (
echo filename. missing.
)
您还可以使用检查丢失的文件IF NOT EXIST.
这个IF命令非常强大.输出IF /?将奖励仔细阅读.就此而言,尝试使用/?许多其他内置命令的选项来获取大量隐藏的宝石.
| 归档时间: |
|
| 查看次数: |
1008294 次 |
| 最近记录: |