I have several folders with different images sharing file names, with a folder structure like this:
/parent/folder001/img001.jpg
/parent/folder001/img002.jpg
/parent/folder002/img001.jpg
/parent/folder002/img002.jpg
/parent/folder003/img001.jpg
/parent/folder003/img002.jpg
...
and would like to copy/rename these files into a new folder, like this:
/newfolder/folder001_img001.jpg
/newfolder/folder001_img002.jpg
/newfolder/folder002_img001.jpg
/newfolder/folder002_img002.jpg
/newfolder/folder003_img001.jpg
/newfolder/folder003_img002.jpg
...
(It's probably better if newfolder isn't a subfolder of parent, since that might end up causing really weird recursion.)
None of the folders containing images have any subfolders.
Ideally, I'd like to be able to reuse the script to "update" newfolder, since I might need to add more folders-containing-images later along the line.
How can I accomplish this with a shell script?