A VBA sub routine for batch renaming/moving/copying of files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Sub RenameOrCopyFiles() Dim OldNamesRange As Range Dim NewNamesRange As Range Dim NumberOfNames As Integer Dim OldName As String Dim NewName As String Dim Task As String Set OldNamesRange = Range("OldNames") Set NewNamesRange = Range("NewNames") NumberOfNames = OldNamesRange.Rows.Count For I = 1 To NumberOfNames OldName = OldNamesRange.Cells(I, 1).Value NewName = NewNamesRange.Cells(I, 1).Value Task = "RENAME" If (Task = "RENAME") Then Name OldName As NewName Else FileCopy OldName, NewName End If Next I End Sub |