-4

I would like to parse Artist and title of song from m3u playlist with batch command

#EXTM3U
#EXTINF:151,TJR - We Wanna Party Into We Want Some Pussy (BB Tribe EDIT)
\#Mixit\pjesme\TJR - We Wanna Party Into We Want Some Pussy (BeatBreaker Tribe EDIT).mp3
#EXTINF:202,Alan Walker - Alone (Prisoners Bootleg)
\Users\Asrock 880\Downloads\Alan Walker - Alone (Prisoners Bootleg).mp3
#EXTINF:236,Alan Walker - Alone 2k17 (#Ash Simons Bangerz) (Ft. Holl & Rush)

so the output .txt file will look like this

TJR - We Wanna Party Into We Want Some Pussy (BB Tribe EDIT)
Alan Walker - Alone (Prisoners Bootleg)
Alan Walker - Alone 2k17 (#Ash Simons Bangerz) (Ft. Holl & Rush)

Any help will be useful, thanks

It can be power shell too or anything other but with a better description I'm DJ... :P

Hotshot
  • 11
  • 1
  • 6

2 Answers2

1
  • So you want only the information on the lines beginning with #EXTINF following the comma.
  • you will find hundreds of examples on [SO] working with findstr to select lines with a pattern (see findstr /?)
  • and also with for /f to parse the content of a line with delimiters and tokens (see for /?)

In a batch:

@Echo off
(For %%M in (*.m3u
  ) Do For /f "tokens=1* delims=," "%%A" in (
    'findstr "^#EXTINF" %%M'
  ) Do Echo %%B
) > Playlists.txt

On the cmd line:

@For /f "tokens=1* delims=," %A in ('findstr "^#EXTINF" playlist.m3u') Do @Echo %B

To redirect to a file enclose the for command in parentheses and append >playlist.txt

  • any way to add more playlist at the same time? – Hotshot May 09 '17 at 17:26
  • This is really basic batch stuff :-( You should put more effort in **your** task. A simple `for` loop can iterate with a wildcard. I'll extend the batch sample above for now but extending a question is a nogo in [SO]. Notice the down votes and the close requests on your question. Take the [Tour] and learn [Ask] –  May 09 '17 at 17:36
  • I'm not kinda into that and I am so sorry... also thankful for your help :) – Hotshot May 09 '17 at 17:45
1

Someone wanted to remove the PowerShell tag, so here is a one liner:

(Select-String *.m3u -Pattern '^#EXTINF') -Replace '^[^,]+,'|Out-File PlayList.txt
  • I like the way you said "Someone wanted to remove the PowerShell tag" :) –  May 10 '17 at 09:09