Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get name of current batch file

1,935 views
Skip to first unread message

JJ

unread,
Dec 2, 2010, 5:21:10 PM12/2/10
to
%0 will give the name as the batch files was called from the command
line. Is there a way to get the actual filename.extension of the
currently executing batch file? And is there then a way to get the
base file name without the extension?

I'm trying to put together a set of batch files that perform similar
tasks. Each one creates a log file named after itself. If I can
retrieve the name of the batch file then I can avoid hard coding the
file name. I'd also like to use the same error subroutine that
displays a usage message containing the full batch file name.

foxidrive

unread,
Dec 2, 2010, 5:58:52 PM12/2/10
to
On 3/12/2010 09:21, JJ wrote:
> %0 will give the name as the batch files was called from the command
> line. Is there a way to get the actual filename.extension of the
> currently executing batch file?

%~nx0

> And is there then a way to get the
> base file name without the extension?

%~n0


See the last two pages of for /?

> I'm trying to put together a set of batch files that perform similar
> tasks. Each one creates a log file named after itself. If I can
> retrieve the name of the batch file then I can avoid hard coding the
> file name. I'd also like to use the same error subroutine that
> displays a usage message containing the full batch file name.


--
Regards,
Mic

JJ

unread,
Dec 3, 2010, 12:39:15 AM12/3/10
to
On Dec 2, 3:58 pm, foxidrive <foxidr...@gotcha.woohoo.invalid> wrote:
>
> %~nx0
>
> %~n0

Thanks!

munish...@gmail.com

unread,
Nov 16, 2012, 8:23:33 AM11/16/12
to
test
0 new messages