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


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/ containing the lines:

nautilus "`dirname "$1"`"

Then I put the following line in the MOC config:

ExecCommand2 = " %f"

Now F2 opens the current directory in nautilus.