cmd - Batch file to search common strings in two text files -


i have 2 text files, all_codes.txt , downloaded_codes.txt wanted compare both text files , log if string missing in downloaded_codes.txt

>all_codes.txt have below strings

a1 a2 a3 

> downloaded_codes.txt have below strings

a1 a3 

in example, a2 missing in downloaded_codes.txt, want log "no" in log.txt if a2 present in downloaded_codes.txt,then want log "yes" in log.txt

this tried, not getting proper result:

@echo off setlocal enabledelayedexpansion  / f "delims=~" % % h in (all_codes.txt)     % % in (downloaded_codes.txt) do(         set found = false         / f "skip=2 tokens=*" % % b in ('findstr /i "%%h" "%%a"') do(           if "!found!" == "false" ((echo yes > log.txt             else(echo no > log.txt)             set found = true           ))         ) 

@echo off  findstr /v /g:downloaded_codes.txt all_codes.txt > nul (if errorlevel 1 (echo yes) else echo no) > log.txt 

edit: example session:

c:\> type test.bat @echo off  findstr /v /g:downloaded_codes.txt all_codes.txt > nul (if errorlevel 1 (echo yes) else echo no)  c:\> type all_codes.txt a1 a2 a3  c:\> type downloaded_codes.txt a1  c:\> test no  c:\> echo a3>> downloaded_codes.txt  c:\> type downloaded_codes.txt a1 a3  c:\> test no  c:\> echo a2>> downloaded_codes.txt  c:\> type downloaded_codes.txt a1 a3 a2  c:\> test yes 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -