ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing File Name (https://www.excelbanter.com/excel-programming/395620-changing-file-name.html)

Akash

Changing File Name
 
Hi,

Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"

Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"

How can i do that....

Thanks

Regards
Akash


joel

Changing File Name
 
Here is the code. Change MyPath to match your filesystem

Sub renamefile()
Dim fs, f, f1, fc, s

Const MyPath = "c:\temp\August 07"
Const OldfileName = "Format for the 1st Aug to 10 Aug"
Const NewfileName = "Current Time Sheet For 1st Aug to 10th Aug"

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyPath)
Set employees = f.SubFolders
For Each employee In employees

Set f1 = fs. _
getfile(employee & "\" & OldfileName)
f1.Name = NewfileName
Next
MsgBox s
End Sub


"Akash" wrote:

Hi,

Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"

Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"

How can i do that....

Thanks

Regards
Akash




All times are GMT +1. The time now is 07:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com