Automate Filename-Tag using Actions

Maybe you can reach your goal with some of this variables:

especially:
%_directory% ---> Name of the parent directory
%_parent_directory% ---> Name of the grandparent folder

And maybe this approach can help too: