I have several folders within a parent folder, which all have the structure below, and am struggling to create a specific loop.
parentfolder/folder01/subfolder/map.png parentfolder/folder02/subfolder/map.png parentfolder/folder03/subfolder/map.png parentfolder/folder04/subfolder/map.png
so each subfolder contains a file called
map.png (i.e. same filename in all subfolders, but they are different files).
I would like to copy each
map.png file and place it into the overall Parentfolder, but at the same time I want the copy to be renamed based on the Folder above 'subfolder'.
So for example, I want to copy
parentfolder/folder01/subfolder to parentfolder whilst renaming it
folder01.png (and for this then to be done accordingly for all others, using a loop).
I have tried something along these lines but am obviously sruggling to get it to do what I want it to:
for i in parentfolder/*; do cd $i cd subfolder cp map.png ../../"$i".png cd - done
I am still a beginner and very new to this so would appreciate any help. Thanks so much.