title: Run a simple command using PowerShell recursively on a directory
body: <p>What's the fastest way using either DOS scripting or PowerShell to run this simple command on a directory and all its subdirectories:</p>
  
  <pre><code> convert filename.jpg -resize 620x620 "R:\processed\filename.jpg"
  </code></pre>
  
  <p><strong>DOS Batch script for single directory</strong>:</p>
  
  <pre><code> FOR %%a in (*.jpg) DO convert %%a -resize 620x620 "R:\processed\%%a"
  </code></pre>
  
  <p>I want to run this recursively on a directory structure and have the output match the input hierarchy. I figured PowerShell was the easiest way, but I was unable to learn PowerShell in the 5 minutes I have to do this task!</p>
  
  <p>Note: not that it's relevant, but <code>convert</code> is from <a href="http://www.imagemagick.org/script/index.php" rel="noreferrer">ImageMagick</a>.</p>