How to strip filename from path so that only parent folder path remains

Basically,

  • if the posix path of the currently selected item in Finder is a folder, leave as is
  • if the posix path of the currently selected item in Finder is a file, remove the filename and keep the path of the parent folder

thank you very much !

Did you consider the filter action with the parent path option? It extracts the path:

And there is also the Split path action.

You can use an If action set to test At this path: A file exists.

thank you very much @kevinb and @DocOck