Get path from txt file
You have at least two options. You can use set
input redirection as well:
set /p myPath=<mypath.txt>nul
where it set /p
will ask for the path, but it <mypath.txt
will work as if the contents of a text file were entered directly.
You can also use a command for
that can iterate over lines in a text file:
for /f "tokens=*" %%x in (mypath.txt) do set myPath=%%x
Both methods actually have slightly different semantics in multi-line files. The first option will store the first line of the file in a variable, the option for
will use the last line. However, this is not important for single line files. Oh, and it may be that the first option may output an empty string; I added a redirect to nul
to remove this.
a source to share