echo off >1.txt for /f %%i in (book.txt) do call :dxy %%i goto :eof :dxy set var=%1 set fname=%~n1 echo ^<a href='%var%' target='_blank'^>%fname%^</a^> >>1.txt cls goto :eof
echo off >1.txt作用是清空1.txt的内容,防止多次运行,内容会重复 第二种问题,也是我本来不知道$~n1这个功能 a.txt内容中的所有.htm都替换为空
echo off >1.txt for /f %%i in (book.txt) do call :dxy %%i goto :eof :dxy set var=%1 echo ^<a href='%var%.htm' target='_blank'^>%var%^</a^> >>1.txt cls goto :eof