-
Solved: Rename the name of files
I have a folder with 1800 files and also i have the list of their name and also i want to change the name of them to new name .(also i have the ne name list)
I write this VBA but this code just rename 1 item how can i add other item to my list ?
Thank you .
[vba]
Sub Rename()
Dim FileName As String
Dim NewFileName As String
On Error Resume Next
FileName = "E:\1.jpg"
NewFileName = "E:\apple-A43.jpg"
Name FileName As NewFileName
End Sub
[/vba]
-
I found it . thanks Xld
[VBA]
Sub RenameFiles()
Dim FilesDir As String
Dim CurFile As String
Dim RowNum As Long
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
FilesDir = .SelectedItems(1)
CurFile = Dir(FilesDir & Application.PathSeparator & "*")
Do Until CurFile = ""
RowNum = 0
On Error Resume Next
RowNum = Application.Match(CurFile, Range("A:A"), 0)
On Error Goto 0
If RowNum > 0 Then
Name FilesDir & Application.PathSeparator & CurFile As _
FilesDir & Application.PathSeparator & Cells(RowNum, "B").Value
End If
CurFile = Dir
Loop
End If
End With
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules