Batch file to retrieve one line at a time and then loop through directories of files to find matches to each line
I have a file of keys and values and wish to step though each key and see if that key occurs at least once (or provide count) in at least one file.
First file looks like this:
"foo.bar" : "hello world", "lorem.ipsum" : "a quick brown fox", ....
and I want to sweep all .js files in subdirectories to see if "foo.bar" is used and provide a count for that key; then take the next key "lorem.ipsum" and sweep all js files in subdirectories to see if it is used and then provide a count.
I get parts of the soltion working but do not get the whole thing working together at once. Challenges has veen findstr does not use /c for count and needing () to keep everything in order.
The outer part I cna get to iterate thourhg each of the lines of the string file...
for /f "skip=1 delims=:" %%a in (src/dict/strs_en.json) do ( findstr /s %%a c:\foo\bar\my\code\*.js )
but internally I need something more like an example that was gien elsewhere in stackoverflow:
for /F "delims=" %G in ('findstr /I /S /M "foo.bar" "%CD%\*.js"') do @find /I /C "home." "%~G" | findstr /V /R "^$"
where "foo.bar" is really my %%a
In the end, desired output would be either (I just want ot know what is used and what is not used)
"foo.bar" 2 "lorem.ipsum" 1 "dolor.et" 0
"foo.bar" - file1.js - file2.js "lorem.ipsum" - file3.js "dolor.et" - "test.me" - file2.js - file3.js
Does the output in
output.loggive you something you can work with after running this batch file:
@(For /F UseBackQDelims^=^" %%A In ("src\dict\strs_en.json") Do @( Echo="%%A" & FindStr/SMC:"%%A" C:\foo\bar\my\code\*.js & Echo=))>output.log