none
Rename a list of files with vba without moving it RRS feed

  • Question

  • Hello everybody

    i have a directory c:\

    123 - AAAAA
    45678 - BBBBB

    How can i rename the files in 

    AAAAA - 123
    BBBBB - 45678

    without touching the subdirectories
    Thanks for all and happy new year
    Tuesday, December 31, 2019 2:36 PM

All replies

  • Don't the files have an extension?

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, December 31, 2019 3:21 PM
  • Public Sub ReNameFiles(sPath As String)
    
        Dim sFile   As String
        
        sFile = Dir(sPath & "\*.*")
        
        Do While sFile <> vbNullString
            If sFile <> "." And sFile <> ".." Then
                Name sFile As newfilename
            End If
            
            sFile = Dir
        Loop
        
    End Sub
    


    Mark

    Tuesday, December 31, 2019 3:28 PM