Pass the parent folder name to a function

Is there a way to pass the name of a selected file's parent folder(s) to a function, just like the [filepath] argument but without pass the whole path.
Tx and sorry for my english.

{filepath$|..} will do that

Aside: You can also use {sourcepath} if you just want the "current" directory, but I guess you need this to work in Flat View or with file collections (e.g. Find Results) where the files may have different parents.