title: One-line way to remove last n characters from string
body: <p>I have a bunch of files in the format <code>photo.jpg.png</code> in a folder, and for every photo in this folder, I want to replace the <code>.jpg.png</code> with <code>.png</code>. How can I do this from Terminal?</p>
  
  <p>I have a basic Python and bash background, so I know I'd want to do something like this:</p>
  
  <pre><code> $ for i in *.png; do mv $i $i[:-8]; done
   $ for i in *; do mv $i $i.png; done
  </code></pre>
  
  <p>But what would I replace the Pythonic <code>[:-8]</code> with in order to remove the last 8 characters of each filename?</p>
  
  <p><strong>EDIT</strong> I now realize that a substring that counts from the end of the string would be superior. Is there a way to do this as well?</p>