你们搞的好复杂啊:
P:- @echo off &cd/d "%~dp0"
- setlocal enabledelayedexpansion
- (for /f "eol= delims=" %%a in (ref.txt) do (
- echo %%a>tmp
- findstr /i "^BATHOME" tmp>nul && (
- for /f "tokens=1,2* delims=," %%i in (tmp) do (
- set "str=%%i"
- set "n1=!str:~11,3!"
- set "n2=!str:~16,4!"
- echo %%i,!n1!!n2!,%%k
- )
- ) || echo %%a
- ))>OK.txt
- del /q tmp
- pause
复制代码 PS版 用BAT运行- @echo off
- PowerShell "$ErrorActionPreference='SilentlyContinue';Foreach ($line in (GC '.\ref.txt' -enc Default)){if ($line -match \"^BATHOME\"){$Array=@(($line.replace('NET','NET/').replace(',','/,/').Replace('WP','/WP/')) -Split('/'));$Array[5]=([string]$Array[1]+([string]($Array[3])).SubString(0,4));$Str='';(0..($Array.Count -1))|%%{$Str=[string]$Str+[string]$Array[$_]};Write-Host $str -fore Yellow;} else {$line;}};"
- pause
复制代码 ================================================== |