Identify files and rename based on cell value

sanket_sk

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

I am stuck with a unique issue, I have a few files (PDF & Jpeg) in a folder, a list of these files is prepared in an excel sheet.

I want to change the name (Rename ) of specific files ( not all only a few files), could you please help me prepare a macro that will help to identify a specific file and rename it as per inputs given in the cell.

Original file name is available in column A, I want to rename it with column B.

Folder pathC:\Users\Data\
File name available in folderFile Name to be renamned
AadharSanket_Adahr Card
PANPramod Pan Card
PassportTeja_Passport
Aadhar01Maharaja_Aadhar


Thanks & Regards,
Sanket
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I have this code that I used to move files which I have modified just to rename files. ( untested)
VBA Code:
Sub movefile()
' this subrouitne move the files to the folder this workbook is in
Dim pathn As String
Dim src As String
Dim dst As String

'pathn = ActiveWorkbook.Path
Worksheets("tobemoved").Select
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 2))
pathn = inarr(1, 2)
For i = 2 To lastrow
'You can change the  file name
    src = pathn & inarr(i, 1)
    dst = pathn & inarr(i, 2)
    Name src As dst
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,454
Members
449,083
Latest member
Ava19

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