![]() |
|
#2
|
|||
|
|||
|
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
Last edited by ranjan; 05-12-2022 at 02:11 AM. Reason: Need to add comment |
| Tags |
| bulk, rename file |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Rename file when sending
|
emmanpelayo | Word VBA | 1 | 09-28-2016 10:05 PM |
| Rename visio file & hyperlink | O'Neill | Visio | 0 | 05-08-2016 11:43 PM |
| Save and rename attachments from ZIP FILE | AndyDDUK | Outlook | 1 | 03-03-2016 12:32 AM |
Rename File
|
cksm4 | Word VBA | 2 | 02-25-2011 09:29 AM |
| How would I bulk select and copy highlights and then bulk paste them automatically? | copywriterpro | Word | 0 | 04-19-2010 05:21 AM |