'Shell Script for moving files to a specific Folder

perhaps someone can point me in the right direction: I want to move certain files which are named on a specific type (e.g. file%AA) to the mirrored place in my archive. So for example i have the following:

livefolder/folder1/file%AA.csv

and want to move it to

archivefolder/folder1/file%AA.csv

When the archive folder does not exist, it should be created. How can i achive this? At the moment i am stuck with this:

find /livefolder/folder1/ -type d  \( -name '*%AA' \) -exec mv {} /archivefolder/folder1/ +

But then i would need to do this for every subfolder which exist. Is there a way to do this recursevily for all subfolders?

I hope someone can point me in the right direction. Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source