When I go to command mode and type
:!mycommand %
I get my command executed on the current file (% is expanded to the current
%
Append :p, e.g.
:p
:!mycommand %:p
And %:p:h will give you the path of the directory that the file resides in.
%:p:h