Rename files based on folder name?

TM Reich

New Member
Joined
Jan 17, 2007
Messages
16
I have a folder for all files for each given project. When I get a new project, I copy the folder "Project 001" with the blank files. I then rename the folder "Project 002".

Is there a way to automatically rename each file in the folder with the project number from the foler name and combine that with other info, i.e. "Project 002 Tasks", or "Project 002 Tracking"?
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
Hi
Save a new workbook inside project 000 folder with the following codes and run the macro
Code:
Sub Reich()
Dim z  As Long, e As Long
Dim f As String
d = InputBox("enter project code")
Application.ScreenUpdating = False
Sheets("Sheet1").Select
Cells(1, 1) = "=cell(""filename"")"
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
MkDir Cells(1, 2) & d
Cells(2, 1).Select
f = Dir(Cells(1, 2) & "*.xls")
    Do While Len(f) > 0
    ActiveCell.Formula = f
    ActiveCell.Offset(1, 0).Select
    f = Dir()
    Loop
z = Cells(Rows.Count, 1).End(xlUp).Row
    For e = 2 To z
        FileCopy Cells(1, 2) & Cells(e, 1), Cells(1, 2) & d & "\" & d & Cells(e, 1)
    Next e
    Application.ScreenUpdating = True
MsgBox "copying is complete."
End Sub
It creates a folder with new project name and copy all files with added project code
Ravi
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,316
Members
414,053
Latest member
Dual Showman

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
Top