Why don't try something like this:
- Find where is the '#' character: indexOf(triggerBody()?['{FileNameWithExtension}'],'#')
- Find where is the last index of '/': lastIndexOf(triggerBody()?['{FileNameWithExtension}'],'/')
- Find how many characters are between them (sub function): sub(lastIndexOf(triggerBody()?['{FileNameWithExtension}'],'/'),indexOf(triggerBody()?['{FileNameWithExtension}'],'#'))
- Length of the folder (without #):
sub(sub(lastIndexOf(triggerBody()?['{FileNameWithExtension}'],'/'),indexOf(triggerBody()?['{FileNameWithExtension}'],'#')),1)
- Get Folder Name:
substring(triggerBody()?['{FileNameWithExtension}'],add(indexOf(triggerBody()?['{FileNameWithExtension}'],'#'),1),sub(sub(lastIndexOf(triggerBody()?['{FileNameWithExtension}'],'/'),indexOf(triggerBody()?['{FileNameWithExtension}'],'#')),1))
Hope it helps!