vbs版的,需要安装office | Dim p, oFSO, s, TCSC | | | | p = "." | | | | Set oFSO = CreateObject("Scripting.FileSystemObject") | | Set TCSC = New TCSCConverter | | s = "" | | Call EnumFiles(oFSO.GetFolder(oFSO.GetAbsolutePathName(p)).Path) | | For Each i In SPlit(Left(s, Len(s) - 2), vbCrLf) | | oFSO.MoveFile i, TCSC.TC2SC(i) | | Next | | | | Class TCSCConverter | | Private Word, Doc | | | | | | | | | | | | Private Sub Class_Initialize() | | Set Word = CreateObject("Word.Application") | | End Sub | | | | Private Sub Class_Terminate() | | Word.Quit | | Set Word = Nothing | | End Sub | | | | | | Public Function TC2SC(str) | | Set Doc = Word.Documents.Add | | Word.Selection.TypeText str | | Doc.Range.TCSCConverter 1, True | | TC2SC = Replace(Doc.Range.Text, vbCr, vbCrLf) | | TC2SC = Left(TC2SC, Len(TC2SC) - 2) | | Doc.Saved = True | | Doc.Close | | Set Doc = Nothing | | End Function | | | | | | Public Function SC2TC(str) | | Set Doc = Word.Documents.Add | | Word.Selection.TypeText str | | Doc.Range.TCSCConverter 0, True, True | | SC2TC = Replace(Doc.Range.Text, vbCr, vbCrLf) | | SC2TC = Left(SC2TC, Len(SC2TC) - 2) | | Doc.Saved = True | | Doc.Close | | Set Doc = Nothing | | End Function | | End Class | | | | Sub EnumFiles(ByVal folderPath) | | Dim oFile, oFolder | | On Error Resume Next | | For Each oFile In oFSO.GetFolder(folderPath).Files | | s = s & oFile.Path & vbCrLf | | Next | | For Each oFolder In oFSO.GetFolder(folderPath).SubFolders | | Call EnumFiles(oFolder.Path) | | Next | | End SubCOPY |
|