Thank you Mr.Yudlugar
i did not sort the file names if need we can sort but the 1.jpg must be (Foldername)-A picture
but we should be care if a image having the name 0E53S (starting from zero).
currently i am using this code
Also when we extract file name to excel it will be as assending order.
i am not a programmer so if any change pls inform
Sub FileRename()
Dim MyFolder As String
Dim MyFile As String
Dim FolderName As String
Dim j As Integer
Dim i As Integer
Dim acount
acount = Range("A" & Rows.Count).End(xlUp).Row
Columns("A:B") = ""
Range("A1").Select
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
MyFolder = .SelectedItems(1)
End With
MyFile = Dir(MyFolder & "\*.*")
Do While MyFile <> ""
j = j + 1
Cells(j, 1).Value = MyFile
MyFile = Dir
Loop
'Range("C1").Value = Split(MyFolder, "\")(UBound(Split(MyFolder, "\")))
FolderName = Split(MyFolder, "\")(UBound(Split(MyFolder, "\")))
If Range("A1").Value <> "" Then
Range("B1").Value = FolderName & "-A.jpg"
End If
If Range("A2").Value <> "" Then
Range("B2").Value = FolderName & "-B.jpg"
End If
If Range("A3").Value <> "" Then
Range("B3").Value = FolderName & "-C.jpg"
End If
If Range("A4").Value <> "" Then
Range("B4").Value = FolderName & "-D.jpg"
End If
If Range("A5").Value <> "" Then
Range("B5").Value = FolderName & "-E.jpg"
End If
If Range("A6").Value <> "" Then
Range("B6").Value = FolderName & "-F.jpg"
End If
If Range("A7").Value <> "" Then
Range("B7").Value = FolderName & "-G.jpg"
End If
If Range("A8").Value <> "" Then
Range("B8").Value = FolderName & "-H.jpg"
End If
If Range("A9").Value <> "" Then
Range("B9").Value = FolderName & "-I.jpg"
End If
If Range("A10").Value <> "" Then
Range("B10").Value = FolderName & "-J.jpg"
End If
If Range("A11").Value <> "" Then
Range("B11").Value = FolderName & "-K.jpg"
End If
If Range("A12").Value <> "" Then
Range("B12").Value = FolderName & "-L.jpg"
End If
If Range("A13").Value <> "" Then
Range("B13").Value = FolderName & "-M.jpg"
End If
If Range("A14").Value <> "" Then
Range("B14").Value = FolderName & "-N.jpg"
End If
If Range("A15").Value <> "" Then
Range("B15").Value = FolderName & "-O.jpg"
End If
If Range("A16").Value <> "" Then
Range("B16").Value = FolderName & "-P.jpg"
End If
If Range("A17").Value <> "" Then
Range("B17").Value = FolderName & "-Q.jpg"
End If
If Range("A18").Value <> "" Then
Range("B18").Value = FolderName & "-R.jpg"
End If
If Range("A19").Value <> "" Then
Range("B19").Value = FolderName & "-S.jpg"
End If
If Range("A20").Value <> "" Then
Range("B20").Value = FolderName & "-T.jpg"
End If
If Range("A21").Value <> "" Then
Range("B21").Value = FolderName & "-U.jpg"
End If
If Range("A22").Value <> "" Then
Range("B22").Value = FolderName & "-V.jpg"
End If
If Range("A23").Value <> "" Then
Range("B23").Value = FolderName & "-W.jpg"
End If
If Range("A24").Value <> "" Then
Range("B24").Value = FolderName & "-X.jpg"
End If
If Range("A25").Value <> "" Then
Range("B25").Value = FolderName & "-Y.jpg"
End If
If Range("A26").Value <> "" Then
Range("B26").Value = FolderName & "-Z.jpg"
End If
For i = 1 To Range("A1").End(xlDown).Row
oldfilename = Cells(i, 1).Value
newfilename = Cells(i, 2).Value
If Not Dir(oldfilename) = “” Then Name oldfilename As newfilename
Next
End Sub
Bookmarks