1

I want to echo the result of dir comamnd in the command prompt. How do I do that? I've already tried:

  1. echo dir
  2. echo $dir
BarYaron
  • 77
  • 8
  • Run `dir` instead of `echo dir`. Please run in the command prompt window the command `help` to get output an incomplete list of [Windows commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands) with a brief description. Every Windows command can be executed with `/?` as argument to get output its usage help in the command prompt window. Try that out with `echo /?` and with `dir /?`. – Mofi Mar 22 '22 at 11:16

1 Answers1

1

an example of this shown in another stackoverflow post is.

FOR /F "delims=" %i IN ('date /t') DO set today=%i
echo %today%

Displays todays current day. u could replace that for dir.

Imbored
  • 11
  • 1
  • Why is used one of the worst examples from all of the thousands of examples which demonstrate how to capture the output of a command line, process the captured output with `for /F`, and define an environment variable with a string value of (part of) captured output? I explained in [this answer](https://stackoverflow.com/a/57189369/3074564) why the first command line in your answer is one of the worst methods to get current date. The first line can be removed and second line changed to `echo %DATE%` to get same output much faster. – Mofi Mar 22 '22 at 11:27