title: "mv: cannot stat" error when using find to move files via xargs
body: <p>I'm working on a bash script that needs to (recursively) move all files and folders within a source folder into a destination folder.  </p>
  
  <p>In trying to make this as robust as possible, and address potential <a href="https://stackoverflow.com/questions/11942422/moving-large-number-of-files">argument list too long - errors</a>, I opted to use the <code>find</code> command (to safely determine the files to move) piped into <code>xargs</code> (to efficiently group the moves together).  I'm also using <code>-print0</code> and <code>-0</code> to address potential problems with spaces.  </p>
  
  <p>I've written the following test script:</p>
  
  <pre><code>#!/bin/bash
  
  # create test source file structure, and destination folder
  mkdir -p sourceDir/{subdir1,subdir\ with\ space\ 2}
  mkdir -p destDir
  touch sourceDir/subdir1/{a1.txt,noExtension1,file1\ with\ space.txt}
  touch sourceDir/subdir\ with\ space\ 2/{a2.txt,noExtension2,file2\ with\ space.txt}
  
  #move files/folders from source to destination
  find sourceDir -mindepth 1 -print0 | xargs -0 mv --target-directory=destDir
  </code></pre>
  
  <p>Which seems to work (i.e. the files are moved) <strong>but</strong> for some reason I get numerous errors as follows: </p>
  
  <pre><code>mv: cannot stat `sourceDir/subdir with space 2/file2 with space.txt': No such file or directory
  mv: cannot stat `sourceDir/subdir with space 2/noExtension2': No such file or directory
  mv: cannot stat `sourceDir/subdir with space 2/a2.txt': No such file or directory
  mv: cannot stat `sourceDir/subdir1/file1 with space.txt': No such file or directory
  mv: cannot stat `sourceDir/subdir1/noExtension1': No such file or directory
  mv: cannot stat `sourceDir/subdir1/a1.txt': No such file or directory
  </code></pre>
  
  <p>Should there not be a way to do this (for the source files indicated in my script) without generating errors?</p>
  
  <p>Why are these errors being generated (since the files and folders are in fact being moved)?</p>