In c:\mydir\ have a series of .xls file, similar:
2500-55545.xls
2500-34344.xls
...
2500-9999.xls
Note:
the first 5 character are the same for all files.
I need to rename all file with AAAA-2500-.......xls
in effect insert AAAA- before the name of file... fow to?
final goal:
AAAA-2500-55545.xls
AAAA-2500-34344.xls
...
AAAA-2500-9999.xls
Rename file in dir...
-
- Administrator
- Posts: 78642
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Rename file in dir...
Here you go:
Code: Select all
Sub RenameFiles()
Const strPath = "C:\MyDir\"
Dim strFile As String
strFile = Dir(strPath & "2500-*.xls")
Do While strFile <> ""
Name strPath & strFile As strPath & "AAAA-" & strFile
strFile = Dir
Loop
End Sub
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Rename file in dir...
Unless you needed code for reasons, you could have used ReNamer.
Excellent app for renaming files in a jiffy!!
Excellent app for renaming files in a jiffy!!
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.