如何将批处理文件输出到一行? [英] How can I output a batch file to one line?
问题描述
我是脚本的新手,因此我需要一些帮助.我已经搜寻了两天,无法掌握!!
I'm new to scripting so I need some help with this. I've searched for two days and cannot grasp this!
我正在做的是扫描目录中的特定文件,然后计算结果并将其传输到文件中.
What I'm doing is scanning a directory for particular files and then counting the results and piping it to a file.
dir *.DONE | find "04338" /c >>04338.txt
所以结果看起来像这样:
So the results look like this:
14
14
(blank line for carriage return)
我的应用程序正在尝试读取此文件,并使用RegEx对它运行命令.该部分工作正常,除非应用程序未使用多行匹配正确分配变量...它将很好地捕获数据,但我无法正确输出.
My application is trying to read this file and run commands against it using RegEx. That part works fine except the application does not assign variables using multi-line match properly... it will grab the data fine but I cannot output it properly.
因此,我必须将所有数据写入一行.最终,我希望它看起来像这样:
Because of this I have to write all of the data to one line. Eventually I want it to look like this:
14,14,14,14,14,14,14
我一生都无法弄清楚如何将其整合到一条线上.请帮忙!
I cannot for the life of me figure out how to get it onto one line. Please help!
推荐答案
尝试一下:
@echo off
for /f "delims=" %%a in ('dir /b /a-d *.DONE ^| find "04338" /c') do <nul set/p "=%%a,">>4338.txt
type 4338.txt
在行尾删除一个,
.
这篇关于如何将批处理文件输出到一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!