You can use the Get File Attribute action to get the Parent Path, and extract the hierarchy from that. But perhaps better would be to use a RegEx to extract the hierarchy of interest:
Put these inside of the KM For Each Action, where FilePath is the For Each variable. Note: I tested the RegEx, but the ==Move is untested.==
You will need to change the paths of INPUT_FOLDER and OUTPUT_FOLDER to match your setup.
ACTIONS: Extract Relative File Path
Note: This is a download of ACTIONS, which will be ==immediately inserted into the current macro at the current location== when you import to KM.
Keyboard Maestro Actions.kmactions (906 B)
Questions?