I have a collection of text files, each one containing a few thousand numbers on separate lines. I would like to use Command line or Powershell to output a file summarizing the data contained in each file, such as below, e.g. Counts.txt:
test.txt: <--Filename
(a) total: 4325 <-- Total number of lines in the file
(b) isbn: 2 <-- Count of numbers that don't start with 3618*
(c) duplicates: 13 <-- (a-b) - (Count of unique numbers that start with 3618*)
The above would be appended to Counts.txt for each file in the directory.
So far I have managed to get the total lines per file to Counts.txt using:
@echo off
setlocal enabledelayedexpansion
set cnt=0
set "out=Counts.txt"
if exist %out% del /q %out%
for /f %%a in ('dir /b /a-d') do (
for /f %%b in ('type "%%a"^|find /v /c ""') do (
set /a cnt=%%b & >>%out% echo(%%~nxa: "-total: %%b")
)
)
Which outputs:
test.txt: -total: 9
How do I get the Count of numbers that don't start with 3618* and the calculation for point (c)?
Some help on formatting would also be appreciated :)