Stripping directory paths to get file names

What I am doing is converting mp3’s with LAME. I already have an old script I wrote that works but I want to add to it this ability–to no longer delete the file but instead save it in a new root folder with sub-directories that match the using the path that it is already in.

Count files in a directory by extension

For the purpose of testing, I’d like count how many images files are inside a directory, separating each image file type by file extension (jpg=”yes”. This because later it will be useful for another script that will execute an action on each file extension). Can I use something like the following for only JPEG files?