Hi,
This Small Code Helps us to Rename file in the Folder… Be Carefull with it..
If Directory.Exists(TextBox1.Text) Then If Not TextBox2.Text = "" Then Dim str As String Dim ct As Integer ct = 0 Try For Each element As String In Directory.GetFiles(TextBox1.Text) ListBox1.Items.Add(element) str = TextBox1.Text & "\" & TextBox2.Text & " " & ct & ".jpg" File.Move(element, str) ct += 1 Next Catch ex As Exception MsgBox(ex.ToString) End Try For Each element As String In Directory.GetFiles(TextBox1.Text) ListBox2.Items.Add(element) Next Else MsgBox("Value Missing") End If Else MsgBox("Directory Not Found") End If
Textbox1 gets the folder name and textbox 2 gets the custom file name… suppose if folder name is,
c:\myname\myfiles
and if all files inside my files should be renamed to file 1, file 2 etc.. then in textbox2 we should give file. Be Careful with Extensions..