Hi,
I've found a few solutions to similar problems but nothing that quite does what I need, or that I can manage to modify to do it.
This is what I have so far. I want to loop down column C - get the filenames from there. Then loop through a specified folder to find those file names and rename them to whatever is in column B. It should be fairly simple, there won't be many files in each folder and the filenames in column c will be exact (just missing the file extension). I'm struggling with looping through the folder and renaming the files.
Edit - I should add, these file could be anything from .oft to .pdf to .html, so I don't want to open them and save them with the new filename - I just want to rename them if possible.
Any help would be great. Thanks.
I've found a few solutions to similar problems but nothing that quite does what I need, or that I can manage to modify to do it.
VBA Code:
Set mb = ThisWorkbook
Set s = mb.Sheets(1)
path = s.Range("C1").Value
If Right(path, 1) <> "\" Then path = path & "\"
For r = 3 To LastRow(s, "B")
If Not s.Range("C" & r).Value = "" Then
name1 = s.Range("C" & r).Value
'loop through each file in the path folder
'if name1 within filename then
'rename file to s.range("B" & r).value with original file extension
End If
Next
This is what I have so far. I want to loop down column C - get the filenames from there. Then loop through a specified folder to find those file names and rename them to whatever is in column B. It should be fairly simple, there won't be many files in each folder and the filenames in column c will be exact (just missing the file extension). I'm struggling with looping through the folder and renaming the files.
Edit - I should add, these file could be anything from .oft to .pdf to .html, so I don't want to open them and save them with the new filename - I just want to rename them if possible.
Any help would be great. Thanks.
Last edited: