ferrariako
New Member
- Joined
- May 5, 2013
- Messages
- 16
I know this question has been asked before... my problem is very similar to this http://www.mrexcel.com/forum/excel-...asic-applications-rename-files-directory.html...
and the solution we got from there looks like this:
now this code works fine for most of the file extension type, it just so happens the the first method can't get the file names for FOLDER types... I want to rename the FOLDERS not files... thanks in advance
and the solution we got from there looks like this:
Sub List_Files()
Dim MyFolder As String
Dim MyFile As String
Dim a As Integer
MyFolder = "C:\DealerExam\" ' <-- Change to your folder
MyFile = Dir(MyFolder & "*.*")
a = 0
Do While MyFile <> ""
a = a + 1
Cells(a, 1).Value = MyFile
MyFile = Dir
Loop
MsgBox "You may now list your new names for each file in Column 'B'." & vbCr & vbCr & _
"All cells must have valid file name. Run 'ReName_Files' Sub when ready."
End Sub
Sub ReName_Files()
Dim r As Integer
r = 1
Do Until IsEmpty(Cells(r, "A")) Or IsEmpty(Cells(r, "B"))
Name Cells(r, "A") As Cells(r, "B")
r = r + 1
LoopMsgBox "All your old file names in Column 'A' have been reNamed" & vbCr & _
"to the adjacent new name in column 'B'."
End Sub
now this code works fine for most of the file extension type, it just so happens the the first method can't get the file names for FOLDER types... I want to rename the FOLDERS not files... thanks in advance
Last edited: