2

This looks for a string %exclude% in a file templist.m3u and puts mismatching lines into file files.m3u.

findstr /irv "%exclude%" "%temp%\templist.m3u%" >%temp%\files.m3u

The problem is that the string %exclude% can sometimes have multiple values, separated by , like s0,s1,s3 with a maximum of -- I don't know -- maybe five values. I need a list where all lines matching any of these values are removed.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Bricktop
  • 533
  • 3
  • 22
  • Possible duplicate:https://stackoverflow.com/questions/12760587/search-multiple-pattern-in-file-and-delete-line-if-pattern-matches – G. C. Dec 15 '19 at 12:22
  • @G.C. I doubt it. This is `batch`. – Bricktop Dec 15 '19 at 12:36
  • 2
    Replace the `,` by _space_ to define multiple search strings for `findstr`... – aschipfl Dec 15 '19 at 12:45
  • 1
    I doubt it does what you say @Bricktop. You stated that it "looks for a string `%exclude%` in a file `templist.m3u`", however it appears to be looking for a string or strings matching the expanded value of the variable, `%exclude%` in a file named `templist.m3u%`! Also based upon your expected variable value content, you may wish to change `%exclude%` to `%exclude:,= %` – Compo Dec 15 '19 at 13:03
  • @Bricktop Let me guess and correct me if i'm wrong, you want just extract all links from the m3u file ? – Hackoo Dec 15 '19 at 13:09
  • @Hackoo, how did you make that determination from the question, my reading in this example is that they want a version with, seasons `2`, `4-9`, `20-29`, and seasons `40-99` etc. – Compo Dec 15 '19 at 13:43
  • 2
    @Compo I don't know if he means by s0,s1,s3 as seasons, but anyway, he should clarify by an example to understand more his aim ! – Hackoo Dec 15 '19 at 13:48
  • 1
    The problem as I see it, is that they're trying to use a command, commands, or a batch file, as a find and replace tool, when there are hundreds of better, quicker and more user friendly ways of doing that. Hell, most basic third party text editors, would do a better job of it, not to mention the built-in WSH or PowerShell functionality, which use proper regular expressions. – Compo Dec 15 '19 at 14:02
  • 1
    @aschipfl solved the issue. Only changed to `%exclude:,= %` and it works beautifully. – Bricktop Dec 15 '19 at 15:19
  • 1
    _...and here was me thinking it was I_ – Compo Dec 15 '19 at 15:42
  • 4
    Are you sure you want the search string(s) to be interpreted as regular expressions? If not, then you want `/ilv` instead of `/irv`. Otherwise something like `.` will match any character instead of a period, and countless other possible gotchas. – dbenham Dec 15 '19 at 15:59

0 Answers0