File name change

MN_Excel

Board Regular
Joined
Nov 8, 2010
Messages
153
I have about 100 different excel files that need to be renamed so that they end with the month and year of the file (ie. Revenue Jan12). Does anyone know of a way to make a massive change to the end of each file or do I need to do each individually?

Thanks,
Jeff
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Are all the files stored in the same directory?
Will the dates be the same, if they're different what is the deciding factor?
 
Upvote 0
Yes, all the files are stored in the same directory and all the files within that directory will need to have the same MMMYY attached to the end.
 
Upvote 0
I have briefly tested this and it worked for me. See how you go with this. You will need to modify some of it to suit, however this could be streamlined further if you want...but it works which is the main point :D

Rich (BB code):
Sub File_name_change()
'For MN_Excel http://www.mrexcel.com/forum/excel-questions/672666-file-name-change.html
Dim filesystem As Object, myfolder As Object
Dim myfiles As Object, myfile As Object, Pastefile As Object
Dim Dte As String
Dim Strt As String
Dim cncat As String

On Error Resume Next

Set filesystem = CreateObject("Scripting.filesystemobject")
Set myfolder = filesystem.getfolder("C:\LOCATION OF THE FOLDER") 'Sets the folder where the files are
Set myfiles = myfolder.Files
Dte = "0512" 'Whatever the constant date is
For Each myfile In myfiles
    Strt = myfile.Name
    cncat = Strt & Dte
    myfile.Name = cncat & ".xls" 'Choose the file extension that suits.
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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