title: How can I rename all files in sub-directories with prefix of sub-directory name and then move files to new directory?
body: <p>I basically have a setup like this:</p>
  
  <pre><code>C:\Upload\A
  C:\Upload\B
  C:\Upload\C
  C:\Upload\D
  C:\Upload\E
  </code></pre>
  
  <p>Where A, B, C, D, E are always different (product IDs) and will always be a different amount (it won't always be 5 sub-directories). Each of these sub-directories contains 24 images numbered numerically 01-24.</p>
  
  <p>I need to create a PHP file that runs remotely through the web (IIS) that looks at the Upload directory, gets the name of each sub-directory and appends that name to beginning of each image file contained within that sub-directory.</p>
  
  <p>So, <code>C:\Upload\A\01.jpg</code> would become <code>C:\Upload\A\A-O1.jpg</code> as well as the other 23 images in each sub-directory.</p>
  
  <p>The PHP file needs to do the same for every sub-directory within the Upload directory.</p>
  
  <p>Then, once the rename is complete, the PHP needs to copy all of the directories (and their images) from the Upload directory to a different directory.  Once copied, the Upload directory needs to be cleared out.</p>