I know that %0 contains the full path of the batch script, e.g. c:\path\to\my\file\abc.bat
I want path to be equal to c:\path\to\my\file.
How can I achieve that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
%~dp0will be the directory. Here’s some documentation on all of the path modifiers. Fun stuff 🙂To remove the final backslash, you can use the
:n,msubstring syntax, like so:I don’t believe there’s a way to combine the
%0syntax with the:~n,msyntax, unfortunately.