以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  马上大佬看一下批量给文件重命名,为什么有些没被重命名啊?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=128770)

--  作者:q1156741089
--  发布时间:2018/12/14 16:00:00
--  马上大佬看一下批量给文件重命名,为什么有些没被重命名啊?
Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
    
    For i As Integer = 0 To FileSys.GetFiles(dlg.SelectedPath).Count -1
        FileSys.RenameFile(FileSys.GetFiles(dlg.SelectedPath)(i),FileSys.GetFiles(dlg.SelectedPath).Indexof(FileSys.GetFiles(dlg.SelectedPath)(i)) & FileSys.GetFiles(dlg.SelectedPath)(i).SubString(FileSys.GetFiles(dlg.SelectedPath)(i).LastIndexOf(".")))
       
        Output.Show(FileSys.GetFiles(dlg.SelectedPath)(i) & FileSys.GetFiles(dlg.SelectedPath).Indexof(FileSys.GetFiles(dlg.SelectedPath)(i))  &  FileSys.GetFiles(dlg.SelectedPath)(i).SubString(FileSys.GetFiles(dlg.SelectedPath)(i).LastIndexOf(".")))
       
       
    Next
   
End If


--  作者:有点甜
--  发布时间:2018/12/14 16:32:00
--  

直接说你要做什么吧,看不懂你的意思。

 

Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
    Dim files = FileSys.GetFiles(dlg.SelectedPath)
    For Each file As String In files
        Dim name As String = FileSys.GetName(file)
        Dim idx = name.LastIndexOf(".")
        If idx >= 0 Then
            FileSys.RenameFile(file, name.SubString(0, idx))
        End If
    Next
End If


--  作者:q1156741089
--  发布时间:2018/12/14 16:39:00
--  
是这样的我有很多文件需要批量重命名(在同一个文件夹下),在用户选择文件下后,遍历该文件夹下的所有文件,将文件一 一重命名,命名要求时,返回当前文件名在集合中的位置再拼接上源文件名的后缀名作为新文件名
--  作者:有点甜
--  发布时间:2018/12/14 17:32:00
--  

Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
    Dim files = FileSys.GetFiles(dlg.SelectedPath)
    Dim i As Integer = 1
    For Each file As String In files
        Dim name As String = FileSys.GetName(file)
        Dim idx = name.LastIndexOf(".")
        If idx >= 0 Then
            FileSys.RenameFile(file, i & name.SubString(idx))
        Else
            FileSys.RenameFile(file, i)
        End If
        i += 1
    Next
End If

 


--  作者:q1156741089
--  发布时间:2018/12/15 10:32:00
--  
谢谢