“vbscript”查找行有相似的单词用冒号分隔“:”[关闭]

问题描述 投票:-3回答:1

我有一个文本文件包含超过5000行,每行有两个单词用冒号分隔,例如(word1:word2)我需要一个脚本比较每行上的(word1)和(word2)如果它们完全匹配它将行保存为它在一个新的文本文件中。预先感谢您的帮助

batch-file vbscript compare similarity difference
1个回答
1
投票

只需将输入文件拖放到此批处理脚本上,您将获得一个新文件,其中相同的单词用冒号分隔:

@echo off
Mode 70,3 & color 0A
Title Find lines have the similar words separated by a colon
set "ScriptName=%~nx0"
if "%~1"=="" goto error
echo(
echo      Find lines have the similar words separated by a colon
Set "OutputFile=newfile.txt"
If exist "%OutputFile%" Del "%OutputFile%"
for /f "tokens=1,2 delims=:" %%a in ('Type %1') do (
    If [%%a]==[%%b] echo %%a:%%b
)>>"%OutputFile%"
Start "" "%OutputFile%" & Exit
::****************************************************************
:Error
Mode 70,5 & color 0C
echo( & echo(
echo      You should drag and drop your file over "%ScriptName%"
Timeout /T 5 /nobreak>nul & exit
::****************************************************************
© www.soinside.com 2019 - 2024. All rights reserved.