title: Move files not in use and preserve directory structure
body: <p>I'm trying to move files from a source folder that is constantly being written to (Files and Folders). Once a file is no longer being written, it won't be r/w again. I want to move the files that aren't in use to another folder, but preserving the directory structure. I will eventually want to add this into a continuous loop or have it run at regular intervals to "clean out" the source folder. </p>
  
  <p>Here is my example before and after:</p>
  
  <pre><code>Before:
  Parent/
  ├── Source/
  │   ├── DirA/
  │   │   ├── File1InUse.abc
  │   │   ├── File2NotInUse.abc
  │   │   └── File3InUse.abc
  │   └── DirB/
  │       ├── File4InUse.abc
  │       ├── File5NotInUse.abc
  │       └── File6NotInUse.abc
  │
  ├── Destination/
  
  After:
  Parent/
  ├── Source/
  │   ├── DirA/
  │   │   ├── File1InUse.abc
  │   │   └── File3InUse.abc
  │   └── DirB/
  │       └── File4InUse.abc
  │
  ├── Destination/
      ├── DirA/   
      │   └── File2NotInUse.abc
      └── DirB/
          ├── File5NotInUse.abc
          └── File6NotInUse.abc
  </code></pre>
  
  <p>I have found <a href="https://superuser.com/questions/219564/how-to-move-files-that-are-not-in-use">answers</a> to moving files that moves files that are not in use:</p>
  
  <pre><code>comm -2 -3 &lt;(find $dir -maxdepth 1 -type f|sort) &lt;(sudo lsof $dir/* | awk '(NR&gt;1) {print $9}'|sort) | xargs -I {} mv {} $move_dir
  </code></pre>
  
  <p>I have also found <a href="https://unix.stackexchange.com/questions/59112/preserve-directory-structure-when-moving-files-using-find">answers</a> to moving files and preserving the directory structure:</p>
  
  <p>maybe with <code>rsync</code>:</p>
  
  <pre><code>rsync -axuv --delete-after --progress Source/ Target/
  </code></pre>
  
  <p>I'm not that knowledgeable in command line so I'm not sure how to put these two concepts together.</p>
  
  <p>Thanks for any help.</p>