title: Move files from folders/subfolders to same folder structure in another folder
body: <p>I have Excel VBA code that move files from one folder to another based on a list in Excel. However, I have to go subfolder by subfolder to get the files.</p>
  <p>I want to modify the script such that it searches for the files from the main folder (that contains subfolders) and moves the respective files to the respective sub folder contained in another main folder with the same folder structure as the original main folder.</p>
  <p>Original folder structure:</p>
  <pre><code>Main Folder1
  |
  |______fold1
  | |_____file1.wav
  | |_____file2.wav
  |
  |______fold2
  | |_____file1.wav
  | |_____file2.wav
  |
  |______fold3
  |_____file1.wav
  |_____file2.wav
  </code></pre>
  <p>The move to folder structure:</p>
  <pre><code>Moved2Folder
  |
  |______fold1
  |
  |______fold2
  |
  |______fold3
  </code></pre>
  <p>Here is the move to script that I use on individual folders:</p>
  <pre class="lang-vb prettyprint-override"><code>    Dim xVal As String
      On Error Resume Next
      Set xRg = Application.InputBox(&quot;Please select the file names:&quot;, &quot;BoBO Man&quot;, ActiveWindow.RangeSelection.Address, , , , , 8)
      If xRg Is Nothing Then Exit Sub
      Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
      xSFileDlg.Title = &quot; Please select the original folder:&quot;
      If xSFileDlg.Show &lt;&gt; -1 Then Exit Sub
      xSPathStr = xSFileDlg.SelectedItems.Item(1) &amp; &quot;\&quot;
      Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
      xDFileDlg.Title = &quot; Please select the destination folder:&quot;
      If xDFileDlg.Show &lt;&gt; -1 Then Exit Sub
      xDPathStr = xDFileDlg.SelectedItems.Item(1) &amp; &quot;\&quot;
      For Each xCell In xRg
          xVal = xCell.Value
          If TypeName(xVal) = &quot;String&quot; And xVal &lt;&gt; &quot;&quot; Then
              FileCopy xSPathStr &amp; xVal, xDPathStr &amp; xVal
              Kill xSPathStr &amp; xVal
          End If
      Next
  End Sub
  </code></pre>
  <p>How to move the found files from the Main Folder1 subfolders to the respective Moved2Folder subfolders?</p>
  <p>I posted this question on the <a href="https://www.mrexcel.com/board/threads/move-files-from-list-found-in-folders-subfolders-to-same-folder-structure-in-another-folder.1204131/" rel="nofollow noreferrer">Mr. Excel website</a>.</p>