title: Bash Script to find, process and rename files?
body: <p>I am trying to put together  a script which will run through all the files on my server (under various subdirectories) , look for .jpeg files and run them through a translator which converts them to non progressive jpgs.</p>
  
  <p>I have:</p>
  
  <pre><code> find /home/disk2/ -type f -iname "*.jpg" 
  </code></pre>
  
  <p>Which finds all the files.</p>
  
  <p>Then if it finds for example 1.jpg, I need to run:</p>
  
  <pre><code>/usr/bin/jpegtrans /file location/1.jpg &gt; /file location/1.jpg.temp
  </code></pre>
  
  <p>The jpegtrans app converts the file to a temp file which needs to replace the original file.
  So then I need to delete the original and rename 1.jpg.temp to 1.jpg</p>
  
  <pre><code> rm /file location/1.jpg
   mv /file location/1.jpg.temp /file location/1.jpg
  </code></pre>
  
  <p>I can easily do this for single files but i need to do it for 100's on my server.</p>