title: Bash convert resize recursively preserving filenames
body: <p>Have images in subfolders that need to be limited in size (720 max width or 1100 max height). Their filenames must be preserved. Started with:</p>
  
  <pre><code>for img in *.jpg; do filename=${img%.*}; convert -resize 720x1100\&gt; "$filename.jpg" "$filename.jpg"; done 
  </code></pre>
  
  <p>which works within each directory, but have a lot of subfolders with these images. Tried <code>find . -iname "*.jpg" -exec cat {}</code> but it did not create a list as expected.</p>
  
  <p>This also didn't work:</p>
  
  <pre><code>grep *.jpg | while read line ; do `for img in *.jpg; do filename=${img%.jpg}; convert -resize 720x1100\&gt; "$filename.jpg" "$filename.jpg"`; done 
  </code></pre>
  
  <p>Neither did this:</p>
  
  <pre><code>find . -iname '*jpg' -print0 | while IFS= read -r -d $'\0' line; do convert -resize 720x1100\&gt; $line; done
  </code></pre>
  
  <p>which gives me error message "convert: no images defined." And then:</p>
  
  <pre><code>find . -iname '*.jpg' -print0 | xargs -0 -I{} convert -resize 720x1100\&gt; {}
  </code></pre>
  
  <p>gives me the same error message.</p>