Hello,
I am attempting to copy a folder and then rename the files in the copied folder with a list derived from an excel workbook. In the excel workbook, column A contains the original name, and Column B contains the new name. Here is a snapshot of the naming "from" and "to" cells:
2021-04-19_16-41-33.png
This code that I have so far just copies the folder. I need to now rename the files as determined by the list given above.
Function GetFolder() As String
Dim fldr As FileDialog
Dim sItem As String
Dim strPath As String
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
' Set fldr = Nothing
strPath = Left(sItem, InStrRev(sItem, "\") - 1)
strPath = filesys.BuildPath(strPath, "Copy1")
' Create the folder "Copy1"
filesys.CopyFolder sItem, strPath
End Function
Bookmarks