3

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)

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!

Endoro
  • 37,015
  • 8
  • 50
  • 63
user2596457
  • 61
  • 1
  • 6

1 Answers1

2

try this:

@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

Remove one , at the end of the line.

Endoro
  • 37,015
  • 8
  • 50
  • 63
  • Thank you. I get: 14, However, if I run this file again, I need it to append the results to the file. If I run the batch again it still only gives me 14,. – user2596457 Jul 18 '13 at 17:09
  • I see, made an edit. Add at the end of all runs `echo(>>4338.txt`. – Endoro Jul 18 '13 at 17:11