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"?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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