title: Mirror only files having specific string in file path
body: <p>I'm trying to mirror only those branches of a directory tree that contain a specific directory name somewhere within the branch. I've spent several hours trying different things to no avail.</p>
  
  <p>A remote FTP site has a directory structure like this:</p>
  
  <pre><code>image_db
    movies
      v2
        20131225
          xyz
            xyz.jpg
        20131231
          abc
            abc.jpg
        AllPhotos   &lt;-- this is what I want to mirror
          xyz
            xyz.jpg
          abc
            abc.jpg
      v4
        (similar structure to 'v2' above, contains 'AllPhotos')
      ...
    tv_shows
      (similar structure to 'movies', contains 'AllPhotos')
    other
      (different paths, some of which contain 'AllPhotos')
    ...
  </code></pre>
  
  <p>I am trying to create a local mirror of only the 'AllPhotos' directories, with their parent paths intact.</p>
  
  <p>I've tried variations of this:</p>
  
  <p><code>lftp -e 'mirror --only-newer --use-pget-n=4 --verbose -X /* -I AllPhotos/ /image_db/ /var/www/html/mir_images' -u username,password ftp.example.com</code></p>
  
  <p>...where the "-X /*" excludes all directories and "-I AllPhotos/" includes only AllPhotos. This doesn't work, lftp just copies everything.</p>
  
  <p>I also tried variations of this:</p>
  
  <p><code>lftp -e 'glob -d -- mirror --only-newer --use-pget-n=4 --verbose /image_db/*/*/AllPhotos/ /var/www/html/mir_images' -u username,password ftp.example.com</code></p>
  
  <p>...and lftp crunches away at the remote directory structure without actually creating anything on my side.</p>
  
  <p>Basically, I want to mirror only those files that have the string 'AllPhotos' somewhere in the full directory path.</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>If I can do this with wget, rsync, ftpcopy or some other utility besides lftp, I welcome suggestions for alternatives.</p>
  
  <p>Trying wget didn't work for me either:</p>
  
  <p><code>wget -m -q -I /image_db/*/*/AllPhotos ftp://username:password@ftp.example.com/image_db</code></p>
  
  <p>...it just gets the whole directory structure, even though the wget documentation says that wildcards are permitted in -I paths.</p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>After further investigation, I am coming to the conclusion that I should probably write my own mirroring utility, although I still suspect I am approaching lftp the wrong way, and that there's a way to make it mirror only files that have a specific string in the absolute path.</p>