
[已解決]批處理如何根據(jù)文本內(nèi)的指定字符串將相關(guān)內(nèi)容生成txt文本并分類存最后由 pcl_test 于 -7-3 19:47我有個(gè)“頻道列表.txt”文件,文件內(nèi)容如下{央視頻道}CCTV1綜合,218.24.47.44/CCTV1.m3u8CCTV1綜合,vdn.apps.cntv.cn/api/getLiveUrlCommonRedirectApi.do?channel=pa://cctv_p2p_hdcctv1&type=ipadCCTV1綜合,vdn.apps.cntv.cn/api/getLiveUrlCommonRedirectApi.do?channel=pa://cctv_p2p_hdcctv1&type=ipadCCTV1綜合,rtmp.cntv.lxdns.com/live/cctv1/playlist.m3u8CCTV2財(cái)經(jīng),218.24.47.44/CCTV2.m3u8CCTV2財(cái)經(jīng),vdn.apps.cntv.cn/api/getLiveUrlCommonRedirectApi.do?channel=pa://cctv_p2p_hdcctv2&type=ipadCCTV2財(cái)經(jīng),218.24.47.44/CCTV2.m3u8CCTV2財(cái)經(jīng),rtmp.cntv.lxdns.com/live/cctv2/playlist.m3u8CCTV3綜藝,stream1.gzcbn.tv:1935/app_2/ls_3.stream/playlsit.m3u8?session=jyb321123CCTV3綜藝,vdn.apps.cntv.cn/api/getLiveUrlCommonRedirectApi.do?channel=pa://cctv_p2p_hdcctv3&type=ipadCCTV3綜藝,116.199.127.68/cctv3CCTV3綜藝,vdn.apps.cntv.cn/api/getLiveUrlCommonRedirectApi.do?channel=pa://cctv_p2p_hdcctv3&type=ipad{地方衛(wèi)視}北京衛(wèi)視,live.gslb.letv.com/gslb?stream_id=bjws&tag=live&ext=m3u8&sign=live_tv北京衛(wèi)視,tvie01.ucatv.com.cn/channels/xjyx/BeiJing-HD-Suma/flv:BJ_HD_Suma北京衛(wèi)視,web-play.pptv.com/web-m3u8-300166.m3u8?type=m3u8.web.pad東方衛(wèi)視,zb.v.qq.com:1863/?progid=3900155972東方衛(wèi)視,live.gslb.letv.com/gslb?stream_id=dongfang&tag=live&ext=m3u8&sign=live_tv廣東衛(wèi)視,zb.v.qq.com:1863/?progid=857894899廣東衛(wèi)視,zb.v.qq.com:1863/?progid=857894899廣東衛(wèi)視,live.gslb.letv.com/gslb?stream_id=guangdong&tag=live&ext=m3u8&sign=live_tv通過批處理遍歷“頻道列表.txt”文件,實(shí)現(xiàn)如下功能:1、遇見中括號(hào)內(nèi)的內(nèi)容如“{央視頻道}”,就通過批處理新建“央視頻道”的文件夾,并把此類別下的鏈接生成txt文件,存放到分類文件夾下2、然后分類的內(nèi)容如“CCTV1綜合,218.24.47.44/CCTV1.m3u8”就生成“CCTV1綜合.txt”文件,“CCTV1綜合.txt”文件內(nèi)容為“218.24.47.44/CCTV1.m3u8”3、由于分類包含的內(nèi)容有重復(fù),如“CCTV1綜合”,遇到第2個(gè)重復(fù)的即在生成的CCTV1綜合.txt后面自動(dòng)累加個(gè)數(shù)字“_1”變成CCTV1綜合_1.txt,以此類推,第3個(gè)就變成CCTV1綜合_2.txt請各位朋友們幫忙看看如何寫,謝謝!

