title: Rename files using bash script
body: <p>I have a bash script set that executes in a folder containing a number of photos and sequentially stitches them into panoramas based on the user input.  Once the generation is completed, the output file is renamed to <code>$x-pano.jpg</code> and moved one folder higher.  </p>
  
  <p>My issue is the number prefix is based on the sequential execution of the script, meaning all files get renamed <code>1-pano.jpg</code> to <code>n-pano.jpg</code> based on the number of panoramas generated during the script execution.</p>
  
  <p>How can I modify the renaming process to look at the storage folder and get the largest <code>$x</code>?  I want to increment that number by 1 and use as the file's numerical prefix.  My current code is</p>
  
  <pre><code>//get the list of files in directory and sort in increasing order
  $filelist=$(find ../ -maxdepth 1 -type f | sort -n)
  
  //get number of files
  $length=${filelist[@]}
  
  //get the last file
  $lastFile=${fileList[$((length-1))]}
  </code></pre>
  
  <p>will get a list of the files, sort in increasing order and get the last file from the list.  This is where I get stuck.  Using <code>-</code> as a delimiter, how can I capture the current value?</p>