One solution if you know the file name:
set fullpath=%~f0 set dirpath=%fullpath:NAME_OF_UR_FILE.EXT=%
You may be able to use vars like $n0 with this, but this was good enough for my use case
$n0