|
|
发表于 2020-9-25 14:36:14
|
显示全部楼层
回复 3# 不会飞的鱼
请参考Q-04和Q-05把bat文件和txt文件都保存为ANSI编码:
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ- @echo off
- setlocal enabledelayedexpansion
- set "NamePre=DummyStr"
- set "CompPre=DummyStr"
- (for /f "delims=" %%a in ('dir /b /a-d *.txt') do (
- echo %%a
- set "OutputStr="
- for /f %%b in ('type "%%a"') do (
- if "%%b" equ "姓名" (
- set "NamePre=%%b"
- ) else if "!NamePre!" neq "DummyStr" (
- set "OutputStr=姓名:%%b"
- set "NamePre=DummyStr"
- ) else if "%%b" equ "单位名称" (
- set "CompPre=%%b"
- ) else if "!CompPre!" neq "DummyStr" (
- set "OutputStr=!OutputStr! 单位:%%b"
- echo,!OutputStr!
- set "CompPre=DummyStr"
- )
- )
- ))>"整合.log"
复制代码 |
|