Reputation: 1094
This is a simple question.
A while ago, when I was writing program, I wrote this:
set /p a=<%~dp0\a.txt
And this worked.
Recently, when I am writing program, I wrote this:
set /p a=<%~dp0\a.txt
And this didn't worked.
So I have to use THIS:
set /p a=<%~dp0a.txt
But it's mysterious. How can I use %~dp0
without \
?
So mysterious. Anybody could explain?
ANY help will be appreciated. Even Commenting.
Upvotes: 2
Views: 1000
Reputation: 41244
Place this in a folder and run it, and look at the end of the path echoed on the screen.
@echo off
echo "%~dp0"
pause
You will see that it has a terminating backslash so a filename can be run against it.
In many cases in modern Windows two \\
in a row in a path will also work, but not all the time.
Upvotes: 2