Hi,
Below code is not working, could anyone help me in this regards...
Your Help is Highly Appreciated.
I want to remove the _Audited from a all files in the path.
Ex:
Input: 12345_Audited.docx, 455678_Audited.rtf
Output: 12345.docx, 455678.rtf
Code:
Sub BulkRename()
Dim strPath As String
Dim objFile As file
Dim objFolder As Folder
Dim objFSO As Scripting.FileSystemObject
strPath = InputBox("Enter Files Path")
strPath = strPath & "\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strPath) Then
Set objFolder = objFSO.GetFolder(strPath)
' Loop through all files in the folder:
For Each objFile In objFSO.GetFolder(strPath).Files
If InStr(objFile.Name, "_Audited") = 1 And InStr(objFile.Name, ".docx" ".rtf") <> 0 Then
'...then copy it with the I removed from the name, overwriting
' an existing version, if necessary:
objFSO.CopyFile objFolder.path & "\" & objFile.Name, objFolder.path & "\" & Mid(objFile.Name, 8), True
objFSO.DeleteFile (objFile.path)
End If
Next objFile
End If
End Sub