Showing Clear Results of Batch File Search?

September 27, 2010 at 13:50:00
Specs: Windows XP
Hi Guys,

Basically, I'm looking to search for multiple strings within a directory of files and then, within the output file - show how many times each string appears.

I'm not bothered about showing how many times the strings appear in each file, only within the main directory.

Is this possible?

For example:

I want to search for the term "ForensicTorch" and "PoliceBaton" within a directory called "PowerPlant" which has multiple sub directories and files within those sub directories. The output file would then show:

Powerplant: ForensicTorch - 10
Powerplant: PoliceBaton - 20

Something like that. Not really much of a programmer, so any help would be appreciated =)

Cheers!


See More: Showing Clear Results of Batch File Search?

Report •

#1
September 29, 2010 at 18:38:27
Maybe something like this:

@echo off

pushd "y:\our\dir"



set torch=0
set baton=0

for /r %%a in (.) do (
    for /f "tokens=3 delims=:" %%b in (' 2^>nul find /c "ForensicTorch" "%%~dpnxa\*" ') do (
        set /a torch += %%b
    )
    for /f "tokens=3 delims=:" %%c in (' 2^>nul find /c "PoliceBaton" "%%~dpnxa\*" ') do (
        set /a baton += %%c
    )
)
echo ForensicTorch - %torch%
echo PoliceBaton   - %baton%
pause


Report •
Related Solutions


Ask Question