Ouch! You are going about this completely wrong. First I will list some errors. Then I will show you a very simple solution.
1) There is no need to place all the lines in a single variable. Each line represents an independent search term. Putting all lines (including linefeeds) in a variable and using that in /C:string
option treats the entire content as a single search term that tries to match the file content with the entire term, including the linefeeds.
2) Even if you really did want all lines in a single variable, your logic is wrong. You are executing your FINDSTR upon each iteration, but you only want to execute it once after the variable is completely populated.
3) The delayed expansion is not working as you expect because you are attempting to use it with a pipe - the value is getting expanded too early. See https://stackoverflow.com/a/8194279/1012053.
4) You state you want to exclude lines that begin with the file content. You need to instruct FINDSTR accordingly.
5) Not an error, but there is no need to use a pipe at all. Simply let FINDSTR read paul.txt directly.
And the simple solution:
findstr /viblg:file.txt paul.txt >edit.txt
Note that I have concatenated the FINDSTR options after a single /
. This is one of many undocumented FINDSTR features.
The /G:file
option instructs FINDSTR to use each line within file as an independent search string.
The /L
option forces the search strings to be interpreted as literal strings (as opposed to regular expressions)
The /B
option forces the search terms to only match the beginning of a line.