Mass change of .xls file names?

B

Bernie Deitrick

?

If you have some logic, you can use a macro to loop through all the files
and rename using the DOS Name command: see an example below.

HTH,
Bernie
MS Excel MVP

Sub RenameFiles()
Dim oldName As String
Dim newName As String
With Application.FileSearch
.NewSearch
.LookIn = "C:\Excel"
.FileType = msoFileTypeExcelWorkbooks
.SearchSubFolders = False
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) Like "*\Book*" Then
newName = Replace(.FoundFiles(i), "\Book", "\Buuk")
oldName = .FoundFiles(i)
Name oldName As newName
End If
Next i
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top