Originally posted by binsea at 2010-4-29 11:46:
好像还是不行,文件名都是汉字就不行了
这个不是汉字问题,而是文件名中有空格的原因,更改如下可解决:
@echo off
for %%a in (*.txt) do (
(for /f "usebackq tokens=1,2" %%b in ("%%~a") do (
if "%%c" equ "乙烯" (
echo %%b %%c
echo %%b 铁矿
echo %%b 铜矿
echo %%b 锡矿
echo %%b 镍矿
) else (
echo %%b %%c
)
))>temp
del /q "%%~a"
ren temp "%%~a"
)
echo 搞定!&pause>nul
回楼上:for 的用法找置顶贴子,讲的很详细