Rename a file based on it's parent folder's name

Let's say I have one master folder that I'm watching called /temp. Within temp, I have a growing number of subfolders. Let's call them:
/temp/folder1
/temp/folder2
/temp/folder3
In any of the folders there could be a .jpeg or a .png. I want to rename that .jpeg or .png to include its parent folder's name and not the /temp folder name.
Thoughts?
/temp/folder1
/temp/folder2
/temp/folder3
In any of the folders there could be a .jpeg or a .png. I want to rename that .jpeg or .png to include its parent folder's name and not the /temp folder name.
Thoughts?