写一个bat批处理将txt文档里的ip段删除中国大陆境内ip后保存
@echo off setlocal enabledelayedexpansion
set "inputFile=input.txt" set "outputFile=output.txt"
if not exist "%inputFile%" ( echo Input file does not exist. exit /b )
REM Set the IP range of China mainland set "chinaIPRange=0.0.0.0-255.255.255.255"
REM Read the input file line by line for /f "usebackq delims=" %%a in ("%inputFile%") do ( REM Check if the current line contains an IP address echo %%a | findstr /r "[0-9].[0-9].[0-9].[0-9]" >nul if not errorlevel 1 ( REM Extract the IP address from the line for /f "tokens=1" %%b in ("%%a") do ( set "ip=%%b" REM Check if the IP address is within China mainland range echo !ip! | findstr /r "^%chinaIPRange%" >nul if errorlevel 1 ( REM Save the IP address to the output file echo !ip!>>"%outputFile%" ) ) ) else ( REM Save the non-IP address line to the output file echo %%a>>"%outputFile%" ) )
echo IP filtering completed. exit /
原文地址: https://www.cveoy.top/t/topic/iMaf 著作权归作者所有。请勿转载和采集!