Question

maybe someone can help me... I have a list (containing also cyrillic letters) like this (channels.txt):

#EXTINF:-1,5 канал Россия
http://95.189.57.162:1234/udp/233.7.70.6:5000
#EXTINF:-0,ТВ3
http://95.189.57.161:1234/udp/233.7.70.7:5000
#EXTINF:-1,ТНТ
rtmp://95.189.54.166:1234/udp/233.7.70.8:5000
#EXTINF:-2,Disney Channel
mms://95.189.52.146:1234/udp/233.7.70.9:5000
#EXTINF:-1,49 Канал
http://95.189.51.163:1234/udp/233.7.70.11:5000

The line begining with #EXTINF: gives the name of a TV channel. Channels are:

  • 5 канал Россия
  • ТВ3
  • ТНТ
  • Disney Channel
  • 49 Канал

The next line is the link to that channel.

Which command or batch script could create a txt file for each channel of the list and put inside the corresponding link? For this example:

  • 5 канал Россия.txt --> http://95.189.57.162:1234/udp/233.7.70.6:5000
  • ТВ3.txt --> http://95.189.57.161:1234/udp/233.7.70.7:5000
  • ТНТ.txt --> rtmp://95.189.54.166:1234/udp/233.7.70.8:5000
  • Disney Channel.txt --> mms://95.189.52.146:1234/udp/233.7.70.9:5000
  • 49 Канал.txt --> http://95.189.51.163:1234/udp/233.7.70.11:5000

I would really appreciate any help! Many thanks!

Was it helpful?

Solution

try this:

@ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "tokens=2 delims=:" %%a IN ('chcp') DO SET /a CurrentCodePage=%%a 2>nul
CHCP 1251 >nul
FOR /f "tokens=1*delims=," %%a IN ('type file.txt') DO (
    SET "link=%%a"
    SET "channel=%%b"
    IF DEFINED channel (SET "fname=!channel!"
    ) ELSE (ECHO !link!)>"!fname!.txt"
)
CHCP %currentCodePage% >nul

dir output is with code page 850:

06/29/2013  08:38 AM                48 49 ?????.txt
06/29/2013  08:38 AM                47 5 ????? ??????.txt
06/29/2013  08:38 AM                46 Disney Channel.txt
06/29/2013  08:38 AM                47 ??3.txt
06/29/2013  08:38 AM                47 ???.txt

dir output is with code page 1251:

06/29/2013  08:38 AM                48 49 Канал.txt
06/29/2013  08:38 AM                47 5 канал Россия.txt
06/29/2013  08:38 AM                46 Disney Channel.txt
06/29/2013  08:38 AM                47 ТВ3.txt
06/29/2013  08:38 AM                47 ТНТ.txt

For more information about cmd and code pages click here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top