@echo off
setlocal enabledelayedexpansion
:: 设置输入文件路径
set "input_file_path=C:\path\to\your\input_file.txt"
:: 设置输出文件路径
set "output_file_path=C:\path\to\your\output_file.txt"
:: 检查输入文件是否存在
if not exist "%input_file_path%" (
echo 输入文件不存在: %input_file_path%
exit /b
)
:: 清空输出文件
if exist "%output_file_path%" del "%output_file_path%"
:: 读取文件并提取符合条件的内容
for /f "tokens=*" %%a in ('type "%input_file_path%"') do (
set "line=%%a"
:: 查找0x34并提取之后的内容
echo(!line!| findstr /r /c:".*0x34," > nul && (
set "line=!line:*0x34,=!"
:: 去除前后空白字符
set "line=!line: =!"
:: 替换多余的逗号
set "line=!line:,,=,!"
:: 去除最后一个逗号
set "line=!line:~0,-1!"
:: 将提取的内容添加到输出文件
echo {!line!}>> "%output_file_path%"
)
)
endlocal