if 判断%1然后goto到%1代表的什么地方在执行代码。简单给你举例把- @echo off
- if not "%~2"=="" (
- if "%~1"=="delfile" goto delfile
- if "%~1"=="addfile" goto addfile
- )
- echo 举例:take del 1.txt
- echo 举例:take add 1.txt
- goto :eof //goto :eof和exit差不多
-
- :delfile
- del "%~2" && echo successfull || echo fail
- goto :eof
-
-
- :addfile
- echo.>"%~2" && echo successfull || echo fail
- goto :eof
复制代码 保存为take.bat |