回复 1# 思想之翼
test-1.bat- @echo off
- cd /d "%~dp0"
- setlocal enabledelayedexpansion
- for /f "tokens=1-2 delims==" %%i in ('findstr /i /g:2.txt 1.txt') do (
- if not defined _%%j (
- set "_%%j=%%i"
- ) else (
- set "_%%j=!_%%j! %%i"
- )
- )
- (for /f "tokens=1-2 delims==" %%i in ('type 1.txt') do (
- echo,!_%%j!
- ))>"2.new.txt"
- endlocal
复制代码 test-2.bat- @echo off
- cd /d "%~dp0"
- setlocal enabledelayedexpansion
- for /f "tokens=1-2 delims==" %%i in ('findstr /i /g:2.txt 1.txt') do (
- if not defined _%%j (
- set "_%%j=%%i"
- ) else (
- set "_%%j=!_%%j! %%i"
- )
- )
- (for /f "delims=" %%i in ('type 2.txt') do (
- echo,!_%%i!
- ))>"2.new.txt"
- endlocal
复制代码
|