本帖最后由 newswan 于 2021-10-4 13:41 编辑
用了第三方命令 sed- @echo off
- setlocal ENABLEDELAYEDEXPANSION
-
- set sour=aaa
- set dest=bbb
- del %dest%\*.txt
-
- set exclude=20210226
-
- for /f "usebackq tokens=* delims=" %%a in (`dir /s /b "%sour%\*.txt"`) do (
- sed -r -n -e "/\w+\s+\w+\s+\w+/p" -e "/%exclude%/d" "%%~fa">> "%dest%\%%~na.txt"
- )
-
- for /f "usebackq tokens=* delims=" %%a in (`dir /s /b "%dest%\*.txt"`) do (
- set _file_=%%~fa
- for /f "usebackq tokens=* delims=" %%a in ("%_file_%") do (
- set __%%a=%%a
- )
-
- (
- for /f "usebackq tokens=2 delims==" %%a in (`set __`) do (
- echo %%a
- )
- ) > "%_file_%"
- rem notepad"%_file_%"
- )
复制代码
|