首页->【软件工具包使用(SW/Software Tools Usage)】

5 1

:: ===============================
::
::Usage
::change the file path of DIR_PATH
::allFileList.txt: save the information about jar tools *.log files
::new1.txt: it all the pattern files list
::FR.txt:find the error pattern files from the allFileList
::Static1.txt Use the find and replace to get the error pattern list            
:: ================================
查找与替换文件,如图所示。

图片.png

::======================================================

@echo off
:: set the color
color 2
cd %DIR_PATH%
::clean the txt file content
del /a /f /q FR.txt 2>nul
del /a /f /q Static1.txt 2>nul
 :: %%~na >> patfile.txt            
for /f "delims=" %%a in (allFileList.txt) do  (
            findstr /i /c:"%%~na.atp"  new1.txt  >> FR.txt           

::由于此文件奇数行都一样,所以只读取奇数行。代码中使用了if 语句          
::  find and replace 将文本文件中 I am hello worda 使用空格代替
set  var=0
setlocal enabledelayedexpansion
for /f "eol=* tokens=*" %%i in (FR.txt) do (
        set "b=%%i"
        if !var!==0 (
           ::echo =========!b!===========
           set "b=!b:I am Hello word= !"
           echo !b! >> Static1.txt
           ::echo =====start====!var!===
           set var=1 ) else (
           set var=0
           ::echo =====dnst==!var!=====
           ::echo =======wr !b!=========
           )
)
pause

楼主可见

  1. shwnyoo 1#

    bat命令之大文件内容批量文件内容查找与替换