按名称按时间顺序重命名文件夹中的文件
Rename files within a folder chronologically by name
我有一个小程序可以重命名文件夹中的文件。
此时它几乎可以工作了;剩下的唯一问题是我希望程序按名称的字母顺序重命名文件。现在这是我的脚本:
If TextBox4.Text = "" Or txtbSti.Text = "" Or ComboBox3.Text = "" Then
MsgBox("Du må velge målmappe og Oppdatere Ønsket Output!", MsgBoxStyle.OkOnly, "Ooooops!")
Else
Dim AntallFiler = My.Computer.FileSystem.GetFiles(txtbSti.Text)
Dim antall As Integer = CStr(AntallFiler.Count)
Dim dir = txtbSti.Text
Dim type = TextBox4.Text
Dim sourcePath As String = dir
Dim searchPattern As String = "*." & ComboBox3.Text
Dim i As Integer = 1
For Each fileName As String In Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories)
File.Move(Path.Combine(sourcePath, fileName), Path.Combine(sourcePath, type & i & "." & ComboBox3.Text))
i += 1
Next
End If
"chronologically by the name" 没有意义......我假设你的意思是按名称排序。
如果是这样,试试这个:
Dim list as New List(of string)
list.AddRange(Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories))
list.Sort();
然后枚举列表。
For Each fileName As String In List
Next
我有一个小程序可以重命名文件夹中的文件。 此时它几乎可以工作了;剩下的唯一问题是我希望程序按名称的字母顺序重命名文件。现在这是我的脚本:
If TextBox4.Text = "" Or txtbSti.Text = "" Or ComboBox3.Text = "" Then
MsgBox("Du må velge målmappe og Oppdatere Ønsket Output!", MsgBoxStyle.OkOnly, "Ooooops!")
Else
Dim AntallFiler = My.Computer.FileSystem.GetFiles(txtbSti.Text)
Dim antall As Integer = CStr(AntallFiler.Count)
Dim dir = txtbSti.Text
Dim type = TextBox4.Text
Dim sourcePath As String = dir
Dim searchPattern As String = "*." & ComboBox3.Text
Dim i As Integer = 1
For Each fileName As String In Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories)
File.Move(Path.Combine(sourcePath, fileName), Path.Combine(sourcePath, type & i & "." & ComboBox3.Text))
i += 1
Next
End If
"chronologically by the name" 没有意义......我假设你的意思是按名称排序。
如果是这样,试试这个:
Dim list as New List(of string)
list.AddRange(Directory.GetFiles(sourcePath, searchPattern, SearchOption.AllDirectories))
list.Sort();
然后枚举列表。
For Each fileName As String In List
Next