@echo off
setlocal enabledelayedexpansion
for /f %%j in ('dir *.txt /b') do (
call :sub %%j
)
del temp.txt
echo 全部完成!
pause >nul
:sub
set /a count=0
for /f "tokens=*" %%i in (%1) do (
set /a count=!count!+1
echo %%i >temp.txt&&ping 127.0.0.1 -n 2>nul|findstr "baidu.com" temp.txt>nul&&echo !count!、%%i >>new_%1||set /a count=!count!-1&&echo %%i >>new_%1
)
echo %1 --^> new_%1 OK!
代码如上。如需修改,有以下关键点:
1、查找关键词。在13行:"baidu.com" (冒号内可替换成其他查找内容)
2、改序号格式。在13行:!count!、%%i (那个顿号可替换为其他)
3、输出文件名。在13行:new_%1 (new_可替换为其他,注此行有两个都要改)