中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-22 18:38
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » doc2txt 批量转换 查看 649 回复 1
楼 主 doc2txt 批量转换 发表于 2009-06-21 05:14 ·  中国 山西 忻州 电信
初级用户
★★
积分 87
发帖 63
注册 2008-08-23 11:28
17年会员
UID 123947
性别 男
状态 离线
除转换doc外,还支持rtf、html转换
ON ERROR RESUME NEXT 
Set fsObject = CreateObject ("Scripting.FileSystemObject")
myDocDir=wscript.arguments(0)
if myDocDir="" then msgbox "请把要转换的文件夹拖到该图标上",,"提示" : wscript.quit
If Not (fsObject.FolderExists(myDocDir)) Then
MsgBox myDocDir & "源文件夹不存在,程序终止。", vbCritical, "错误"
Wscript.Quit
End If

If InStrRev(myDocDir, "\") < Len(myDocDir) Then
myDocDir = myDocDir & "\"
End If

Set DocFilesDir = fsObject.Getfolder(myDocDir)
Set myDocFiles = DocFilesDir.Files
Set myObject = Wscript.CreateObject("Word.Application")

n = 0
For Each DocFile In myDocFiles
hz=LCase(Right(DocFile.Name,3))
If hz = "doc" or hz="rtf" or hz="tml" or hz="htm" Then
TextFileName =myDocDir & Left(DocFile.Name,InStrRev (DocFile.Name, ".")) & "txt"

myObject.Documents.Open DocFile.Path,,,,,,,,,,,False
myObject.Documents(DocFile.Path).Activate
myObject.ActiveDocument.SaveAs TextFileName, 2
myObject.ActiveDocument.Close
n = n + 1
End If

Next

If n > 0 Then
MsgBox n & "个文件成功转换!"
Else
MsgBox "转换失败!"
End If
myObject.Quit
Set myObject = Nothing

2 发表于 2009-06-21 22:57 ·  新加坡
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
论坛跳转: