Zend certified PHP/Magento developer

Find all files of x file type and copy them, moving them into subfolders matching pattern [closed]

So this is quite a complex one that I’m struggling with.

I have a big folder structure containing lots of sub directories and different file types. Inside there’s a bunch of directories with consistently formatted names like so:

  • 08312018-archive-19483
  • 04132019-archive-84224

I need to drill down into all subdirectories and copy the .jpgs from them but I’d like to organise them into folders based on these names.

If I can list all the paths to jpgs I need with Find, like so:
find . -iname "*.jpg" -not -name ".*"

And get a list like:

  • root/04132019-archive-84224/bin/blah/image1.jpg
  • root/subdirectory/05122019-archive-43543/image2.jpg
  • etc

Can I then do a pattern match for the XXXXXX-archive-XXXXX in the path and use that as a parent directory for the copy.