Saving current path to a var (problem with pipe)
Posted: 09 Mar 2008 13:06
I started writing Batch scripts just now, and they already prove very useful. But right now there's something I don't get. Using the | character, you use a pipe to send the output of one program to the input of another. Very un-Windows-like, at least. This works perfectly:
the date command expects a new date in this format, and that's what i supply.
Now I want to save the current directory to a variable, but somehow this doesn't work:
"set /p [VARNAME]=" prompts for a value to assign to VARNAME, and I'm giving it the output of cd. It refuses to work.
For some strange reason, this works:
Thanks for any hints, I'm somewhat in the dark here
Code: Select all
echo 03-09-08 | date
the date command expects a new date in this format, and that's what i supply.
Now I want to save the current directory to a variable, but somehow this doesn't work:
Code: Select all
cd | set /p folder=
"set /p [VARNAME]=" prompts for a value to assign to VARNAME, and I'm giving it the output of cd. It refuses to work.
For some strange reason, this works:
Code: Select all
cd > tmp
set /p folder= < tmp
Thanks for any hints, I'm somewhat in the dark here