Getting the parent folder name

I'm trying to create a new folder with the name of the current folder, but in a different path.

For example, I select a file "C:\XXX\B\1.txt" and I would like to create a button that will copy it to "C:\ZZZ\B\1.txt"
Same goes with "C:\XXX\A\2.txt" --> "C:\ZZZ\A\2.txt"

The C:\XXX and C:\ZZZ are always the same, but B and A are dynamic.

Any suggestions?

Okay, I found it.
I can use {sourcepath|nopath} the rest is straight forward.

The {sourcepath} arguments returns the current path. You can add |.. to this to get the parent path, and also add nopath to get just the name. For example,

Copy TO C:\ZZZ\{sourcepath|..|nopath}