且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

批处理脚本从一个文本文件的行复制到ID的另一个基地

更新时间:2023-11-27 22:26:28

所有的ID匹配的12或56文件中的 IDFile.txt 将被输出到一个新文件 MatchingIDs.txt

All ID's matching either 12 or 56 in the file IDFile.txt will be outputted into a new file MatchingIDs.txt.

@echo off
setlocal enabledelayedexpansion
set line=0
for /f "tokens=2 delims=|" %%a in (IDFile.txt) do (
set num=%%a
set num=!num: =!
if !num!==12 set bool=true
if !num!==56 set bool=true
if "!bool!"=="true" call :GETLINE
set /a line+=1
set bool=false
)

:GETLINE
if not %line%==0 set skip=skip=%line%
for /f "%skip% tokens=* delims=" %%b in (IDFile.txt) do (
echo %%b >>MatchingIDs.txt
goto :BREAK
)
:BREAK