So i want to change directory and view the new directory contents automatically with out having to type cd folder
and then dir
on the next line. Is there a way to adjust the settings on the windows cmd prompt such that every time you change directory it lists the contents automatically?

- 3
- 2
-
1You can do two commands in one line like shown here https://stackoverflow.com/questions/8055371/how-do-i-run-two-commands-in-one-line-in-windows-cmd – Sunley95 Aug 22 '18 at 13:49
2 Answers
Yes & No.
What you can do, is make cd
and alias for cd & dir
:
doskey cd=cd $* ^& dir
Note that these aliase are by standard only avaible for the session you define them. To use this alias persistent take a look at the tutorials I linked at the bottom.
Explanation:
doskey
- create an alias/makro using doskey.exe
cd $*
- Use cd
with the argument given to the alias
^&
- This uses the normal &
for two commands with the ^
to as escape character
dir
-make an dir
in the directory you just moved in
Additional info about doskey
can be found here:
How to set an alias in Windows Command Line?
Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey
Additional warning (Thanks to @eryksun):
Note that doskey.exe
is a command-line interface to the console's input alias and history facilities.
Console aliases are implemented in the console itself (i.e conhost.exe
). They're defined per executable name (e.g. cmd.exe
or python.exe
), match at the beginning of a line, and replace the text that's read by the process via ReadFile
or ReadConsole
.
This means you cannot pipe into an alias or use one in a batch script. For that you need a custom batch script.

- 2,959
- 1
- 20
- 34
-
1Note that doskey.exe is a command-line interface to the console's input alias and history facilities. Console aliases are implemented in the console itself (i.e conhost.exe). They're defined per executable name (e.g. cmd.exe or python.exe), match at the beginning of a line, and replace the text that's read by the process via `ReadFile` or `ReadConsole`. This means you cannot pipe into an alias or use one in a batch script. For that you need a custom batch script. – Eryk Sun Aug 22 '18 at 17:36
-
Im not 100% sure, i have never done that before but i have seen that you are able to do multiple commands in one line, the way to do this differs slightly depending on operating systems and other factors.
If this is what you are meaning then it has been mentioned and answered previously here

- 21
- 10