I am trying to rename a bunch of .m3u files based on the text between ", and (s. The text might contain characters including & (random text) . : ! | -
So I need to remove the colon and the pipe. There is also white space before and after that I'd like to remove.
Here are two examples
in channel1.m3u
#EXTINF:-1 group-title="Documenteries" logo="/img/icon.png",: Animal Planet (s-6)
http://*********.m3u8
in channel2.m3u
#EXTINF:-1 group-title="Misc" logo="/img/icon.gif", PAC-12 Net. (Bay Area) 1080P (s-8)
http://*********.m3u8
Here is the batch file I have so far
@echo off
cd Renamed_Files
for /f "delims=" %%i in ('dir /a-d/b *.m3u') do (
set "nname="
set "fname=%%~i"
for /f "tokens=* delims=,(" %%f in ("%%~i") do if not defined nname set "nname=%%f"
setlocal enabledelayedexpansion
echo rename "!fname!" "!nname!.m3u"
endlocal
)
pause
This gives me everything before the comma. If I change delims=,( to delims=( it gives me everything up to the Bracket, so I get the text I'm after, but I get all the text before it as well. The characters before the text I want are always ", and the characters after are always (s- if that helps.
This could be either a batch file or vbscript. Any help would be greatly appreciated.