title: OSX Terminal delete last 7 Characters of Filename
body: <p>Hi is there an easy way to rename a bunch of files like:</p>
  
  <pre><code>A_16-25-55-313.txt
  </code></pre>
  
  <p>and</p>
  
  <pre><code>B_16-25-55-313.txt
  </code></pre>
  
  <p>so that all the Files in the Folder look like:</p>
  
  <pre><code>A_16-25.txt
  </code></pre>
  
  <p>and</p>
  
  <pre><code>B_16-25.txt
  </code></pre>
  
  <p>In this example case I would have to get rid of the last 7 Characters before the extension.
  I used the OS X terminal
  and tried stuff like:</p>
  
  <pre><code>for i in *.txt do set fName==$i
  do mv $fName $fName:~0,-7.txt
  </code></pre>
  
  <p>which didn't work and:</p>
  
  <pre><code>for i in *
  do
  j=`echo $i | sed -e ’s/.......$//‘`
  mv $i $j
  done
  </code></pre>
  
  <p>which did not work as well.</p>