I am using Manjaro Gnu/Linux and I have a directory named
files. Under this directory, I have around 650 sub directories, with names such as:
Under each sub directory there are varying number of
.jpg images (say, from 2 to 11).
Say as an example, under
dir1 subdirectory, the images are
I want to write a command/script to copy all such images to a new directory names
all_images such that the images are renamed to the names of their sub directories.
For example: For
dir1 sub directory,
imgaf001.jpg changes to
srep0001.jpg changes to
dir1_2.jpg (after the underscore, the count of image comes).
How can I achieve this?