title: Convert all images to jpg
body: <p>I need to convert all images in folder and subfolders to jpg. I need to batch this process with command file. GUI tools needles for me I need the script.</p>
  
  <p>I tried to use mogrify.exe from ImageMagick, there is also convert.exe function, but afaik both of them are able to convert images.</p>
  
  <p>I wrote next script:</p>
  
  <pre><code>$rootdir = "E:\Apps\скрипты\temp1\graphics"
  $files = dir -r -i *.png $rootdir
  foreach ($file in $files) {.\mogrify.exe -format png *jpg $file}
  </code></pre>
  
  <p>But it is not work, when I try to run it, I got errors:</p>
  
  <pre><code>mogrify.exe: unable to open file `*jpg' @ error/png.c/ReadPNGImage/3633.
  mogrify.exe: Improper image header `E:\Apps\скрипты\temp1\graphics\telluric\day\
  Athens\2011-07-03-17.png' @ error/png.c/ReadPNGImage/3641.
  mogrify.exe: unable to open image `*jpg': Invalid argument @ error/blob.c/OpenBl
  ob/2588.
  </code></pre>
  
  <p>Also I have find next code:</p>
  
  <pre><code>[Reflection.Assembly]::LoadWithPartialName('System.Drawing')
  
  $img=[Drawing.Image]::FromFile("$(cd)\Max.jpg")
  $img.Save("$(cd)\max.gif", 'Gif')
  $img.Dispose()
  </code></pre>
  
  <p>How I can get it work with tree of dirs and convert png and tiff to jpg?</p>