How to pass the path of the directory to an external program

Hello.

I am trying to open a nautilus window of the folder MOC is playing. I tried to put

ExecCommand2 = "nautilus %f"

in the config file. But %f passes not only the path of the folder but also the name of the file. Is there a way to pass only the path of the folder to nautilus?

I created a script /usr/bin/naut_dir.sh containing the lines:

#!/bin/bash
nautilus "`dirname "$1"`"

Then I put the following line in the MOC config:

ExecCommand2 = "naut_dir.sh %f"

Now F2 opens the current directory in nautilus.