Hello harky,
This will move files and folders within the parent folder (Column "A") to the destination folder (Column "B"). If you want to only move the files in the parent folder then add the flag FOF_FILESONLY to the flags variable. This will not overwrite files that have the same name but will add and index number like (1) to the file name. If a destination folder does not exist then it will be created. If the parent folder is empty it will be deleted.
Sub MoveFilesAndFolders()
Dim Cell As Range
Dim flags As Long
Dim fldrFrom As Object
Dim fldrTo As Object
Dim objShell As Object
Dim Rng As Range
Dim Wks As Worksheet
' // Folder Operation Flags
Const FOF_MULTIDESTFILES = &H1 ' The pTo member specifies multiple destination files (one for each source file in pFrom) rather than one directory where all source files are to be deposited.
Const FOF_SILENT = &H4 ' don't create progress/report
Const FOF_RENAMEONCOLLISION = &H8 ' Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists at the destination.
Const FOF_NOCONFIRMATION = &H10 ' Respond with Yes to All for any dialog box that is displayed.
Const FOF_ALLOWUNDO = &H40 ' Preserve undo information, if possible. If the source file parameter does not contain fully qualified path and file names, this flag is ignored.
Const FOF_FILESONLY = &H80 ' Perform the operation only on files (not on folders) if a wildcard file name (*.*) is specified.
Const FOF_SIMPLEPROGRESS = &H100 ' Display a progress dialog box but do not show individual file names as they are operated on.
Const FOF_NOCONFIRMMKDIR = &H200 ' Do not ask the user to confirm the creation of a new directory if the operation requires one to be created.
flags = FOF_SILENT Or FOF_RENAMEONCOLLISION Or FOF_NOCONFIRMMKDIR Or FOF_ALLOWUNDO
Set objShell = CreateObject("Shell.Application")
Set Wks = ActiveSheet
Set Rng = Wks.Cells("A1", Wks.Cells(Rows.Count, "A").End(xlUp))
For Each Cell In Rng.Cells
Set fldrFrom = objShell.Namespace(Cell.Value)
Set fldrTo = objShell.Namespace(Cell.Offset(0, 1).Value)
If fldrFrom.Items.Count = 0 Then
RmDir fldrFrom.Self.Path
Else
fldrTo.MoveHere fldrFrom, flags
End If
Next Cell
End Sub