本帖最后由 dengyuli 于 2014-11-23 13:51 编辑
可以通过替换特定字符串来实现智能化。- @echo off
- setlocal enabledelayedexpansion
- for /f "delims= tokens=* eol=?" %%a in (%~1) do (
- set b=%%a
- set c=!b:关闭回显=@echo off! & set b=!c!
- set c=!b:修改背景颜色=color! & set b=!c!
- set c=!b:暂停=pause! & set b=!c!
- set c=!b:如果=if ! & set b=!c!
- set c=!b:执行结果不显示在屏幕上=^>nul! & set b=!c!
- set c=!b:执行结果不显示到屏幕上=^>nul! & set b=!c!
- set c=!b:即使出现错误也不显示=^2^>nul! & set b=!c!
- set c=!b:显示=echo ! & set b=!c!
- set c=!b: 不 =not ! & set b=!c!
- set c=!b:存在=exist ! & set b=!c!
- set c=!b:大于等于= geq ! & set b=!c!
- set c=!b:小于等于= leq ! & set b=!c!
- set c=!b:不等于= neq ! & set b=!c!
- set c=!b:大于= gtr ! & set b=!c!
- set c=!b:小于= lss ! & set b=!c!
- set c=!b:等于===! & set b=!c!
- set c=!b:的话= (! & set b=!c!
- set c=!b:判断结束=^)! & set b=!c!
- set c=!b:否则=^) else ^(! & set b=!c!
- set c=!b:赋值=set! & set b=!c!
- set c=!b:交互模式=/p! & set b=!c!
- set c=!b:计算=/a! & set b=!c!
- set c=!b: 其表达式为:==! & set b=!c!
- set c=!b:累加=+=! & set b=!c!
- set c=!b:##=%%! & set b=!c!
- set c=!b:循环结束=^)! & set b=!c!
- set c=!b:循环,=for ! & set b=!c!
- set c=!b:文本解析=/f! & set b=!c!
- set c=!b:遍历目录=/r! & set b=!c!
- set c=!b:计数循环=/l! & set b=!c!
- set c=!b:分隔符为:=delims=! & set b=!c!
- set c=!b:取用的节:=tokens=! & set b=!c!
- set c=!b:忽略以此字符打头的行:=eol=! & set b=!c!
- set c=!b:从此行的下一行开始处理:=skip=! & set b=!c!
- set c=!b:要读取的文档为:=in ! & set b=!c!
- set c=!b:定义局部变量为=%%%%! & set b=!c!
- set c=!b:执行以下命令:=do (! & set b=!c!
- set c=!b:初始值:=! & set b=!c!
- set c=!b:步长:=! & set b=!c!
- set c=!b:终止值:=! & set b=!c!
- set c=!b:标签 =:! & set b=!c!
- set c=!b:跳转至=goto :! & set b=!c!
- set c=!b:程序尾部=eof! & set b=!c!
- set c=!b:调用=call ! & set b=!c!
- set c=!b:输出到文件并覆盖=>! & set b=!c!
- set c=!b:输出到文件并追加=>>! & set b=!c!
- set c=!b:刷新屏幕=cls! & set b=!c!
- set c=!b:的使用方法= /?! & set b=!c!
- set c=!b:颜色设置=color! & set b=!c!
- set c=!b:黑色=0! & set b=!c!
- set c=!b:蓝色=1! & set b=!c!
- set c=!b:浅绿色=a! & set b=!c!
- set c=!b:绿色=2! & set b=!c!
- set c=!b:红色=4! & set b=!c!
- set c=!b:紫色=5! & set b=!c!
- set c=!b:黄色=6! & set b=!c!
- set c=!b:白色=7! & set b=!c!
- set c=!b:亮白色=f! & set b=!c!
- set c=!b:设置窗口大小=mode con! & set b=!c!
- set c=!b:窗口高度为:=lines=! & set b=!c!
- set c=!b:窗口宽度为:=cols=! & set b=!c!
- set c=!b:标题:=title ! & set b=!c!
- set c=!b:注释:=rem ! & set b=!c!
- set c=!b:提示是否删除=/p! & set b=!c!
- set c=!b:强制删除=/f! & set b=!c!
- set c=!b:删除 =del ! & set b=!c!
- set c=!b:包括其子文件夹下的所有指定文件=/s! & set b=!c!
- set c=!b:安静模式=/q! & set b=!c!
- set c=!b:要删除的文件的属性:=/a:! & set b=!c!
- set c=!b:只读文件=R! & set b=!c!
- set c=!b:隐藏文件=H! & set b=!c!
- set c=!b:无内容索引文件=I! & set b=!c!
- set c=!b:非=-! & set b=!c!
- set c=!b:系统文件=S! & set b=!c!
- set c=!b:存档文件=A! & set b=!c!
- set c=!b:创建目录:=md ! & set b=!c!
- set c=!b:不提示覆盖已存在的文件=/y! & set b=!c!
- set c=!b:复制文件=copy ! & set b=!c!
- set c=!b:到= ! & set b=!c!
- set c=!b:删除目录=rd ! & set b=!c!
- set c=!b:及其子文件夹= /s! & set b=!c!
- for /l %%a in (1,1,100) do (
- if "!c:~-1!"==" " (
- set c=!b:~0,-1!
- set b=!c!
- ) else (
- break
- )
- )
- echo ^!c!>>a.bat
- )>nul 2>nul
- call a.bat
- del /f /q a.bat >nul 2>nul
复制代码
|