I am given to maintain some batch files and i repeatedly see this line in the beginning of every batch file..
FOR /f \"usebackq tokens=*\" %%a IN (\'%0\') DO
@Santhosh: %0 would be how the current batch file was called. That could be any of the following forms: abc.bat, abc (no .bat suffix), ..\..\abc.bat, d:\path\to\abc.bat, "e:\path with spaces\to\abc.bat" and probably some more.
Now, using %0 for further processing will not work in any case, since it is not there in a canonical form. You'll use
%~0 : to remove quotes which may appear around %0 (if any);%~n0 : to just use the name of %0 without suffix;%~nx0 : to use the name+suffix of %0;%~pnx0 : to use path+name+suffix of %0 (without drive letter);%~dpnx0: to use driveletter+path+name+suffix of %0.The same can be used for sanitizing %1 (first argument to %0), %2 etc. in case these arguments are files or directories.