Skip to main content

How to rename multiple files of a folder in Excel?

May be most of us are suffered with this problem that we need to rename multiple files in a folder, to rename the filenames one by one will make us crazy if there are hundreds or thousands files in that folder. Are there any good functions for us to deal with this task?

List all file names from a specific folder in worksheet with kutools for Excel

Rename multiple files of a folder in Excel with VBA code


If there are multiple files that you want to rename, first, you can list the old file names in a column of worksheet, and then enter the new filenames that you want to replace with. To quickly list all files in worksheet, you can use the Kutools for Excel’s Filename List utility.

After installing Kutools for Excel, please do as follows:( Free Download Kutools for Excel Now )

1. Click Kutools Plus > Import & Export > Filename List, see screenshot:

2. In the Filename List dialog box, click doc-rename-multiple-files-1 button to choose the file folder that you want to list the files, and then click All files from the Files type, see screenshot:

doc-rename-multiple-files-1

3. Then click OK button, all the filenames have been list in a column of a new worksheet, as well as some file attributes, and now, you can delete other unwanted columns and only leave the File Name column, see screenshot:

doc-rename-multiple-files-1

Click to know more about this Filename List feature…

Free Download Kutools for Excel Now


After listing all original filenames in one column A, and you should type new filenames in column B as following screenshot shown:

doc-rename-multiple-files-1

And here I will talk about a VBA code which may help you to replace the old filenames with the new filenames at once. Please do with following steps:

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications Window.

2. Click Insert > Module, and paste the following macro in the Module window.

VBA code: Rename multiple files in a folder

Sub RenameFiles()
'Updateby20141124
Dim xDir As String
Dim xFile As String
Dim xRow As Long
With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
If .Show = -1 Then
    xDir = .SelectedItems(1)
    xFile = Dir(xDir & Application.PathSeparator & "*")
    Do Until xFile = ""
        xRow = 0
        On Error Resume Next
        xRow = Application.Match(xFile, Range("A:A"), 0)
        If xRow > 0 Then
            Name xDir & Application.PathSeparator & xFile As _
            xDir & Application.PathSeparator & Cells(xRow, "B").Value
        End If
        xFile = Dir
    Loop
End If
End With
End Sub

3. After pasting the code, please press F5 key to run this code, and in the Browse window, select the folder which you want to change the filenames in, see screenshot:

doc-rename-multiple-files-1

4. And then click OK, all the old filenames have been replaced by the new filenames immediately. See screenshots:

doc-rename-multiple-files-1  2 doc-rename-multiple-files-1

Notes:

1. When you list your old and new filenames, the file extension must be included.

2. In the above code, the reference A:A indicates the old filenames list you want to rename, and reference B contains the new filenames that you want to use, you can change them as your need


Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!

Related articles:

How to create sequence worksheets from a range of cells in Excel?

How to rename multiple worksheets in Excel?

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (38)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Great! it work for me
This comment was minimized by the moderator on the site
The above stated code does not detect native language file names in Hindi or Marathi - example "HIN-MALE-CH - 7 - कार"
Here the code does not detect "कार"
Any way to handle this issue?
This comment was minimized by the moderator on the site
Sziasztok!
Ha kép nevébe "/" jelet akarok rakni, akkor min kell változtatnom?
Ha benne van a "/" jel akkor nekem nem működik.

Köszönöm
Andor
This comment was minimized by the moderator on the site
Hello, Benedeczki,

Under normal circumstances, the file name cannot contain the /\:*?<>” symbol, so if your picture name contains the / symbol, the code cannot run normally.
You'd better to remove the / symbol from the file name.
Thank you!
This comment was minimized by the moderator on the site
wow, useful and very helpful. BIG THANKS :)
This comment was minimized by the moderator on the site
Sub RenameMultipleFiles()
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
selectDirectory = .SelectedItems(1)
dFileList = Dir(selectDirectory & Application.PathSeparator & "*")

Do Until dFileList = ""
curRow = 0
On Error Resume Next
curRow = Application.Match(dFileList, Range("A:A"), 0)
If curRow > 0 Then
Name selectDirectory & Application.PathSeparator & dFileList As _
selectDirectory & Application.PathSeparator & Cells(curRow, "B").Value
End If

dFileList = Dir
Loop
End If
End With
End Sub

this formula does not rename1st document
This comment was minimized by the moderator on the site
Love this so much! Is there a way to use Kutools to edit metadata tags for music similar to this with filenames? Would love being able to mass edit song tags through Excel rather than on iTunes or other third party song tag editors. Thank you!
This comment was minimized by the moderator on the site
okay Thank you
This comment was minimized by the moderator on the site
Hello. I did this for a couple of files and it worked successfully. The next few files i tried, did not work. There were a few formulas added to the new names, could that be the issue?
This comment was minimized by the moderator on the site
Very helpful. Thank you!
This comment was minimized by the moderator on the site
great, worked great for me
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations