title: Insert characters into a filename
body: <p>I have a directory with a bunch of files that are titled (for example)</p>
  
  <pre><code>how it is:            how it should be:
  945TITLE-1.txt        945TITLE-00.txt
  945TITLE-10.txt       945TITLE-01.txt
  945TITLE-2.txt        945TITLE-02.txt
  945TITLE-23.txt       945TITLE-03.txt
  945TITLE-3.txt        945TITLE-10.txt
  945TITLE.txt          945TITLE-23.txt
  </code></pre>
  
  <p>The numbers and the text which proceed the dash character can change so it needs to be variable.
  Ignoring the file which is unnumbered (945TITLE.txt in this instance)
  I'm using the following line to grab all the files which end in a dash and a single digit</p>
  
  <pre><code>file=`ls -1 working/pages/files | grep [-][0-9].txt`
  </code></pre>
  
  <p>But now I cannot figure out how to splice in the 0 between the dash and the digit.</p>
  
  <pre><code>for file in $filelist
  do  
  ????
  done
  </code></pre>
  
  <p>After several attempts I got furthest with this:</p>
  
  <pre><code>for file in working/pages/files/$filelist
  do  
  f1=${filelist%%[-]*}
  f2=${filelist##*[-]}
  finalName=${f1}-0${f2}
  echo $finalName
  mv $file working/pages/files/$finalName
  done
  </code></pre>
  
  <p>The output for <code>$finalName</code> is <code>945TITLE-03.txt</code> every time and it only applies the <code>mv</code> command to <code>945TITLE-1.txt</code> (incorrectly changing it to <code>945TITLE-03.txt</code>) and  saying that it cannot find the other files (since it only looked the <code>working/pages/files/</code> folder for the first file)</p>
  
  <p>Any help would be much appreciated and I am in no means married to this solution so if you can think of a more elegant one however different from what I'm proposing, I would be more than happy to hear it. Thank you</p>