Hi all, and thank you in advance for your time.
I have created a file renaming tool using Excel and VBA. Basically it will take an unlimited amount of files in a folder and rename them according to a pre-defined data-set. It won't just add or swap a piece of the name like most rename tools, but allow us to use data that we have to rename 1k+ files in one go. The Excel sheet has an "Old Name" column, a "New Name" Column, a user defined field for the folder/filepath and a macro run button.
As an example let's say I need to rename files from 1, 2, 3 and 4 to A, B, C, and D and all the files are in the same folder. The code (below) I've cobbled together will do it.
However if files 1 and 2 are in the specified folder, but file 3 is in a subfolder and file 4 in a subfolder of that, how can I get the code to look in those folders for files to rename?
Thanks again for any suggestions or tips!
Working code (but only in specified folder and not subfolders yet):
Sub Rename() On Error Resume Next strPath = Range("C2") 'this is the user defined filepath taken from the sheet Dim r As Long Dim n As Long n = Cells(Rows.Count, 1).End(xlUp).Row For r = 2 To n Name strPath & Cells(r, 1) As strPath & Cells(r, 2) Next r On Error GoTo 0 End Sub