Rename files using bash script
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 $x-pano.jpg and moved one folder higher. My issue is the number prefix is based on the sequential execution of the script, meaning all files get renamed 1-pano.jpg to n-pano.jpg based on the number of panoramas generated during the script execution. How can I modify the renaming process to look at the storage folder and get the largest $x ? I want to increment that number by 1 and