PDA

View Full Version : DOS Command Output Redirection


mlse
07-07-2006, 01:14 PM
Hi all,

Simple question: How do I redirect the output of a DOS command (say CHDIR - to find the current working directory) to some kind of variable in the batch file?

In a Linux C-Shell script it is painfully easy:


#!/bin/csh
set cwd=`pwd`
echo $cwd


In DOS, however, I can't seem to do this simple thing at all!

A little help please .... Thanks!

Mike.

ghostdog74
07-07-2006, 04:16 PM
for /f "tokens=*" %%a in ("%cd%") do echo %%~na

mlse
07-07-2006, 05:14 PM
Thanks for that!