Help to rename files

  • Thread starter Thread starter Hilton
  • Start date Start date
H

Hilton

Is there a way I can rename files:

AFT.11.DAT
AFT.12.DAT
AFT.21.DAT
AFT.22.DAT
(not the 2 "dots")

to

SEG11.DAT
SEG12.DAT
SEG21.DAT
SEG22.DAT

Thanks
Hilton
 
Why don't you just change the names? What is the issue here?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Assume source data in A1 down
In B1: =SUBSTITUTE(A1,"AFT.","SEG")
Copy down
 
Modify this to rename instead of move. Something like this. TEST
oldname = "C:\x\" & FN
newname = "C:\y\" & "Sig"& right(FN,len(fn)-3)



Sub Movefiles()

Application.ScreenUpdating = False
Dim FN As String
FileLocation = "c:\x\*.xls"
FN = Dir(FileLocation)
Do Until FN = ""

If Mid(FN, 4, 1) = "_" Then
oldname = "C:\x\" & FN
newname = "C:\y\" & FN
Name oldname As newname
End If
FN = Dir
Loop
Application.ScreenUpdating = True
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

Back
Top