以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关键文件遍历代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=67936)

--  作者:wh420
--  发布时间:2015/5/6 17:24:00
--  关键文件遍历代码

For Each file As String In FileSys.GetFiles(path)

 If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
 ‘如何将目录中含有扩展名为XLS或XLSX的文件统一命名为: 主文件名 & ".DOCX"

    Dim filename As String = file & ".docx"

end if

 

如:目录有文件1.XLS、2.xlsx将其批量命名为:1.docx 2.docx


--  作者:Bin
--  发布时间:2015/5/6 17:25:00
--  
利用这个判断文件后缀名 http://www.foxtable.com/help/topics/2707.htm


--  作者:大红袍
--  发布时间:2015/5/6 17:30:00
--  
Dim path As String = "d:\\"
For Each file As String In FileSys.GetFiles(path)
    If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
        Dim finfo As New FileInfo(file)
        FileSys.RenameFile(file, finfo.Name.Replace(finfo.Extension, ".docx"))
       
    End If
Next