Here is another help code and tool for programmers to rename files.
You can use this tool for renaming all files available in a selected folder. Just browse the folder and hit ‘Rename Files’ button. This tool is available free on our website, please go through this and let us know your thoughts in comments section.
Though this tool can be downloaded for free however we are pasting the code here, if someone wanna play with this customization. Here you just copy the code and paste it in Excel VB Editor Window and start using it.
'This function loops through all the files listed in the sheet and
'rename them as per details provided by user
Public Sub RenameFiles()
   '
   'Variable declaration
   Dim lCounter As Long
   Dim lInnerCounter As Long
   Dim bHasError As Boolean
   Dim strPath As String
   '
   'Clear Status field
   Sheet1.Range("E7:E" & Sheet1.Rows.Count).ClearContents
   '
   'Check if New File Name is not left blank
   bHasError = False
   For lCounter = 7 To Sheet1.Range("C" & Sheet1.Rows.Count).End(xlUp).Row
       If Trim(Sheet1.Range("D" & lCounter).Value) = "" Then
           Sheet1.Range("E" & lCounter).Value = "New File Name cannot be left blank"
           bHasError = True
       End If
   Next
   If bHasError = True Then
       MsgBox "There are few validation errors." & vbNewLine & vbNewLine & "Please check column E (Status) for details.", vbInformation
       Exit Sub
   End If
   '
   'Check if there are duplicate file names
   For lCounter = 7 To Sheet1.Range("C" & Sheet1.Rows.Count).End(xlUp).Row
       For lInnerCounter = lCounter + 1 To Sheet1.Range("C" & Sheet1.Rows.Count).End(xlUp).Row
           If Trim(LCase(Sheet1.Range("D" & lCounter).Value)) = Trim(LCase(Sheet1.Range("D" & lInnerCounter).Value)) Then
               Sheet1.Range("E" & lCounter).Value = "Duplicate File Name"
               bHasError = True
               Exit For
           End If
       Next
   Next
   If bHasError = True Then
       MsgBox "There are few validation errors." & vbNewLine & vbNewLine & "Please check column E (Status) for details.", vbInformation
       Exit Sub
   End If
   '
   'Store path in a variable and add slash to it
   strPath = Sheet1.Range("C3").Value
   If Right(strPath, 1) <> "/" And Right(strPath, 1) <> "\" Then
       strPath = strPath & "\"
   End If
   'Rename files
   For lCounter = 7 To Sheet1.Range("C" & Sheet1.Rows.Count).End(xlUp).Row
       On Error GoTo Error_FileRename
       '
       'Use Name function to rename file
       Name strPath & Sheet1.Range("C" & lCounter).Value As strPath & Sheet1.Range("D" & lCounter).Value
       '
       'Update status column as success
       Sheet1.Range("E" & lCounter).Value = "Success"
       '
       On Error GoTo 0
   Next
   '
   'Show confirmation to user
   MsgBox "Done", vbInformation
   '
   Exit Sub
   '
'Error Handler if file rename produces error
Error_FileRename:
   MsgBox "An error occurred while renaming file '" & Sheet1.Range("C" & lCounter).Value & "'." & vbNewLine & vbNewLine & "Error: " & Err.Description, vbCritical
   Sheet1.Range("E" & lCounter).Value = "Failed"
   Exit Sub
End Sub
Note: Just in case if the tool is not able to rename a few files, you will get those details in the Status column.
Hope it resolves your problem. Please do share this with your friends and colleagues.
Please do comment below with your thoughts.
If you wanna explore more excel utility tools, click here
What is the Usage of sheet color in Excel? When we prepare a report or a dashboard it is easy to identify or analyze reports with a change of color sheet tabs. Analysts generally give…
Excel Add-in helps you to extend the features of Excel application. Using Excel Add-in, you can perform custom actions in Excel such as formatting the data, doing complex calculations which are not possible through Excel formulas, Reading or Writing data in other Excel files and so many more actions.
This guide explains the basics of Excel’s Advanced Filter and shows you how to use it to find records that match one or more complicated conditions.
If you’ve read our previous guide, you know that Excel’s regular filter offers different options for filtering text, numbers, and dates. These options work well for many situations, but not all. When the regular filter isn’t enough, you can use the Advanced Filter to set up custom criteria that fit your exact needs.
Excel’s Advanced Filter is especially useful for finding data based on two or more complex conditions. For example, you can use it to find matches and differences between two columns, filter rows that match another list, or find exact matches with the same uppercase and lowercase letters.
Advanced Filter is available in all Excel versions from 365 to 2003. Click the links below to learn more.
Time & Motion Tracker is an MS Excel based tool which helps you to track Start and End time of any type of transaction or activity. The tool is developed using VBA coding which helps you to protect manual manipulation in the data by the user. It is also easy to use, just click on Start (shortcut: Ctrl+Shift+A) or Stop (Ctrl+Shft+S) buttons to record the time stamp.
VBA Code to Find Last used Column or Row in Excel Sometimes as a developer, you need to take actions in Excel sheets based on last row or column. In Excel, there are two kinds…
Time and Motion Tracker is an MS Excel based tool which helps you to track Start and End time of any type of transaction or activity. The tool is developed using VBA coding which helps you to protect manual manipulation in the data by the user. It is also easy to use, just click on Start (shortcut: Ctrl+W) or Stop (Ctrl+E) buttons to record the time stamp. This is professional version of our famous Time & Motion Tracker. This version includes features such as Hold Timer, Consolidation, Utilization Analysis, Dashboards etc.
Hi
I downloaded the File Rename Tool and it did not run.
Asking fo the password to unprotect the sheet.
Please help.
Thanks,
Hi Trong,
Thanks for highlighting the issue.
We have now removed the password from the sheet. Please download the latest copy of the tool from below URL:
https://excelsirji.com/wp-content/uploads/2019/05/File-Rename-Tool.zip
Thanks,
Your Excel mate
ITS NOT GETTING DOWNLOADED
I have fixed the issue. Please let me know if you still see the issue.
After clicking on ‘browse folders’ button, it gives me this error:
“Cannot run the macro “File Rename Tool.xlsm’!PickAFolder’. The macro may not be available in this workbook or all macros may be disabled.
I have checked and all my macros are enabled in excel.
You need to enable the macro or save it on Desktop to run the same.