机顶盒EPG菜单自动处理程序20131118
本系列文章由ex_net(张建波)编写,转载请注明出处。
http://blog.youkuaiyun.com/zjianbo/article/details/16808121
作者:张建波 邮箱: 281451020@qq.com 电话:13577062679 欢迎来电交流!
用来处理网上下载的各个电视台节目单,按照一定的规律处理后,导入服务器,就可以下发给机顶盒了。
以下程序适用于处理2013年10、11、12月的节目
主要处理2个内容:从网上下载的节目单中截取“下个星期”的内容,并格式化日期。
dim fileName
Set objArgs=WScript.Arguments
fileName=objArgs(0)
Call Main()
Sub Main()
Dim fso,OutFile,InFile
Set fso=CreateObject("Scripting.FileSystemObject")
'fileName=OpenFileDialog()
Set InFile=fso.OpenTextFile(fileName,1,True)
Set OutFile=fso.CreateTextFile(fileName+".out.txt",Ture)
dim OK
OK=0
do until InFile.atendofstream
strline=InFile.readline
'开始截取日期
if strline="13/10/28" then
OK=1
end if
if OK=1 then
OutFile.WriteLine(Fx(strLine))
end if
loop
InFile.close
OutFile.Close
Set fso=nothing
Msgbox "文件处理完成!转换后的文件名为"+fileName+".out.txt"
End Sub
Function Fx(str)
'星期替换
str=Replace(str,"13/10/28","13/10/28 星期一")
str=Replace(str,"13/10/29","13/10/29 星期二")
str=Replace(str,"13/10/30","13/10/30 星期三")
str=Replace(str,"13/10/31","13/10/31 星期四")
str=Replace(str,"13/11/01","13/11/01 星期五")
str=Replace(str,"13/11/02","13/11/02 星期六")
str=Replace(str,"13/11/03","13/11/03 星期天")
Fx=str
End Function
function OpenFileDialog()
OpenFileDialog=inputbox("请输入文件名?")
end function
下面给个截图示意
感兴趣的朋友,可以把上面的代码复制到“记事本中”,另存为 jm.vbs 文件即可。
使用的时候,把要处理的 文本文件,拖到上面即可自动运行处理。