VBA Rename Every File In Folder

Sub RENAME_FILES_IN_FOLDER() Dim objFSO As Object Dim objFile As Object Dim firstLast As String Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFolder As Object Set objFolder = objFSO.GetFolder("C:\Users\nkoutavas\Cropped\Left\") '<---Directory To Search In '====Do This for Every File in Folder===== For Each objFile In objFolder.Files 'objFile.Name = Mid(objFile.Name, InStr(1, objFile.Name, "124081", vbTextCompare), 99) objFile.Name = "Side A " & Replace(objFile.Name, ".jpg", " Left.jpg") Next '====END Do This for Every File in Folder===== 'Clean up! Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.