VBA – Quick Renamer of files in folders with VBA

Hi there, if you ever need a quick renamer of files in forlders – that is the VBA code you may use:

Option Explicit

Sub ChangeNames()

Dim fso As New filesystemobject

Dim fol As Object
Dim fil As Object
Dim counter As Integer
Dim digit As String
Dim sname As String

    Set fol = fso.GetFolder("C:\Users\chinese")

    For Each fil In fol.Files
        counter = Len(fil.Name)
        Debug.Print fil.Name
        digit = Left(fil.Name, counter - 4)
        sname = digit & "_Chinese.mp3"
        fil.Name = sname
        Debug.Print sname
    Next

End Sub

What it does? It enters the directory “C:\users\chinese” and renames any file there adding “_Chinese” to its name.

We had files like this “4.mp3; 723.mp3” and we get something as “4_Chinese.mp4”, “723_Chinese.mp3”. This is useful, if you only have VBA and you need to code it!

So far so good! 🙂