title: Batch rename files in mac os x bash with regexp
body: <p>I have a specific case of files set:</p>
  
  <pre><code>80e505bf3611cabea7de90e2ba-movies-c7185328dd51ef480b7d8c71873fbabf-ultra-low_000005_10-23.mov
  80e505bf3611cabea7de90e2ba-movies-c7185328dd51ef480b7d8c71873fbabf-ultra-low_000006_9-87.mov
  80e505bf3611cabea7de90e2ba-movies-c7185328dd51ef480b7d8c71873fbabf-ultra-low_000007_10-18.mov
  80e505bf3611cabea7de90e2ba-movies-c7185328dd51ef480b7d8c71873fbabf-ultra-low_000008_9-02.mov
  </code></pre>
  
  <p>And I need to write a bash script for batch renaming all of these files in current directory to match the following result:</p>
  
  <pre><code>ultra-low_000005.mov
  ultra-low_000006.mov
  ultra-low_000007.mov
  ultra-low_000008.mov
  </code></pre>
  
  <p>The following script I made is removing the constant prefix part from all these files:</p>
  
  <pre><code>#!/bin/bash
  
  echo "Input prefix and press ENTER:"
  read prefix
  echo "Your prefix will be: $prefix"
  echo "Continue? y/n:"
  read continue
  if [ $continue == "y" ]
  then
    for f in $prefix*; 
    do 
      mv "$f" "${f#$prefix}"; 
    done
  fi
  </code></pre>
  
  <p>But this script leaves files with the last unwanted part:</p>
  
  <pre><code>ultra-low_000008_9-02.mov
  </code></pre>
  
  <p>So I suppose it can be done with properly constructed regexp, but I have not succeed with it.</p>