string - Count total words from text file serperated by "," (comma) in batch script -
i have comma d eliminated text file (names.txt) in there string ex mike,joe,kelly.
i need total count of strings : total name : 3 , store result in variable , call further in batch script. googled lot not getting proper code.
it great if can answer expert group. lot in advance.
a simple way, 1 command line: ( name count return value %errorlevel%
)
msr -p your-file.txt -t "," -o "\n" -pac | msr -t "\w+"
store variable:
name count ?
set /a namecount=%errorlevel%
full string ?
set "resulttext=total name : %errorlevel%"
additionally, if want hide output of command, redirect output nothing >nul
:
msr -p your-file.txt -t "," -o "\n" -pac | msr -t "\w+" >nul
msr.exe
/ msr-win32.exe
single portable exe tool file processing cross platform versions. see tools
directory in open project https://github.com/qualiu/msr . can see: https://qualiu.github.io/msr/usage-by-running/msr-windows.html
Comments
Post a Comment