Friday, June 24, 2005

DOS shell command output to %VAR%

In Linux its quite easy to get the output of a command into a variable for future use. In Windows..., well, no quite so easy.

FOR /F %%B IN ('d:\utils\date +%%Y%%m%%d-%%H%%M') DO SET DATE=%%B

The 'date' command in this examples is the Win32 GNU port of the equivalent Linux command.

For use in CMD or BAT scripts in Windows.