VBA- Rename files based on cell value

sanket_sk

Board Regular
Joined
Dec 27, 2016
Messages
140
Office Version
  1. 365
Platform
  1. Windows
Hi There,

Hope you all are doing good,

I need your help here.

I have multiple files in folders as well as in subfolders, list of these files is available in excel column A, I want to rename these files with cell values in column B.

I am looking for VBA/Macro who will go through folders/ subfolders, check the file name and rename these files with column B value.

Note:- These files can be excel, Word, or with any extension- we do not have any restrictions here.

Folder Path: C:\Users\Documents\Projects\


Sample files
Sample.jpg

Sample data
Book1
AB
1Origional File name in folderName to be changed with
2Mumbai Maharashtra _Mumbai
3Delhi Delhi _Delhi
4Bangalore Karnataka _Bangalore
5Hyderabad Telangana _Hyderabad
6Ahmedabad Gujarat _Ahmedabad
7Chennai Tamil Nadu _Chennai
8Kolkata West Bengal _Kolkata
9SuratGujarat _Surat
10PuneMaharashtra _Pune
Sheet1
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Here is the special missing line.
VBA Code:
name oldName as newName

See this thread.
Rename files in folder

Practice this simple version of renaming the files and once you have that going smoothly, ask again on how to change the file names in subfolders
as that would be more involved answer.
 
Upvote 0
I think this is what you are looking for... great tutorial...

 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,317
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top