Reputation: 1159
I need to remove some specific data inside a business file. All occurrences of these Data must be removed from the business file entirely. I note that Data are written in another file and each of them is on a single line.
The first argument is the data file and the second one is business file in which data that have been just reading will be removed. I have written a batch, unfornatunately no data is removed from my business file. Indeed, output file "result.txt" matches "%~2" in every particular.
@for /F "usebackqdelims=" %%a in ("%~1") do (
findstr /v /c:%%a "%~2" >result.txt
)
At the end of processing, result.txt should not have any data request to be removed.
If needed, look at structure of my data file. Some of these items appear in business file.
ab@&t/fr
$gr;top
a^p/usa
Please, help me out!
Upvotes: 0
Views: 49
Reputation: 80138
FINDSTR /g:"%~1" /L /v /b /e "%~2" >u:\result.txt
should accomplish this goal.
/g:
gets the strings-to-match from a file. /L
forces a literal (not regex) match. /b /e
forces that match to be against lines that BEGIN and END with the strings - so it matches ONLY if there is an exact match - not just if there is a partial match.
Upvotes: 2