windows批处理脚本将多行组合成逗号分隔的单行

时间:2022-09-20 00:17:14

I have text file like below strings in multiple rows

我有多行文本文件,如下面的字符串

1234
234545
123
16322

I need a output like using windows batch script

我需要一个像使用Windows批处理脚本的输出

1234,234545,123,16322

1 个解决方案

#1


4  

Try this:

@echo off
setlocal EnableDelayedExpansion
set "txt="
set input=input.txt
for /f "delims=" %%a in (%input%) do (
  set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!

#1


4  

Try this:

@echo off
setlocal EnableDelayedExpansion
set "txt="
set input=input.txt
for /f "delims=" %%a in (%input%) do (
  set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!