I'm trying to process an m3u playlist file structured as is:
#EXTM3U
#EXTING:193,Song name
/path/to/the/song.mp3
#EXTING:201,Another song
/somewhere/in/a directory/song2.mp3
The aim is, for every line containing a path, remove the path and keep only filename and extension. For example, the file above would become:
#EXTM3U
#EXTING:193,Song name
song.mp3
#EXTING:201,Another song
song2.mp3
I tried with awk several variations, the closest I could get was this one:
awk '{if ((NR % 2 == 1) && (NR != 1)){print "$(basename $0)"}else{print}}' playlist.m3u
The if/else structure is ok, only the "print basename" thing doesn't work, and I have to admit that shell is not my strong suit ;)
Can someone help?
Thanks a lot!