I have this easy script in hello.cmd
for %%a in (*.*) do if not "%%a"=="%0" del %%a
I tried running it but it seems that the current script hello.cmd gets deleted, as i know %0
should return the path to the current file but it don't.
I also tried running in another script just echo %0
and i get returned %0
instead of the path.
So i was wondering why it doesnt return c:\path\to\file\hello.cmd
? Is there another way to get the current path?
@ECHO OFF
SETLOCAL
ECHO %%0=%0
ECHO %%~f0=%~f0
ECHO %%~dpnx0=%~dpnx0
ECHO %%~nx0=%~nx0
ECHO %%~p0=%~p0
Perhaps this might help. Notice what happens when you use simply hello
instead of hello.cmd