windows - batch file that searches for strings in a text file inside all files in folders/subfolders -


i have text file (sample.txt) has 500 strings , have folder (package) has many sub-folders many files of different file types(.xml, .cpp, .hpp, few more).

sample.txt looks like

gi_70_1 if_mne_70f_black backserver type_gradient area_round 

i need search these strings in files in "package" folder , print path found in result.txt

here had managed till now

@echo off set result_file="result.txt"  /f %%i in (sample.txt) ( pushd %~p0 type nul > %result_file%.tmp /f "delims=" %%a in ('dir /b /s *.txt') (     /f "tokens=3 delims=:" %%c in ('find /i /c "%%i" "%%a"') (         /f "tokens=*" %%f in ('find /i "%%i" "%%a"') if %%c neq 0 echo %%f ) ) >> "%result_file%".tmp move %result_file%.tmp %result_file% >nul 2>&1 )    :: open file "%result_file%" popd 

but prints search string name found , last searched string, not all.

could me this

findstr /m /l /i /g:sample.txt "package\*" 

should find files in package directory contain of strings in sample.txt file.

see findstr /? prompt documentation. naturally, you'll need substrtute pathname "package"

add /s switch search subdirectories too.


add >filename command put output file.

add if errorlevel 1 echo not found>filename put string not found file if no strings found


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -