Here are two examples
in channel1.m3u
Code: Select all
#EXTINF:-1 group-title="Documenteries" logo="/img/icon.png",: Animal Planet (s-6)
http://*********.m3u8
in channel2.m3u
Code: Select all
#EXTINF:-1 group-title="Misc" logo="/img/icon.png", PAC-12 Net. (Bay Area) 1080P (s-6)
http://*********.m3u8
The text might contain characters including
Code: Select all
"& (text) . * : | ! and -"
Here is one the batch files I have tried so far
Code: Select all
@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 parenthesis, 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 another one I have tried
Code: Select all
@echo off&setlocal
cd Renamed_Files
for /f "delims=" %%i in ('dir /a-d/b Channel*.txt') do (
set "nname="
set "fname=%%~i"
for /f "usebackq delims=" %%f in ("%%~i") do if not defined nname set "nname=%%f"
setlocal enabledelayedexpansion
set "nname=!nname:~85,40!"
echo rename "!fname!" "!nname!".txt
endlocal
)
pause
This gives me the info I want, but it also shows illegal characters. If I remove the echo it outputs "system cannot find path specified", "filename, directory name, or volume label syntax is incorrect." and some files have "A duplicate file name exists, or the file cannot be found."
I can do simple things with batch files, but this is a bit over my head.