Is there a way to automatically show the contents of a directory after a cd change in the windows cmd?

Is there a way to automatically show the contents of a directory after a cd change in the windows cmd?



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?


cd folder


dir





You can do two commands in one line like shown here stackoverflow.com/questions/8055371/…
– Sunley95
Aug 22 at 13:49




2 Answers
2



Yes & No.
What you can do, is make cd and alias for cd & dir:


cd


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


doskey


doskey.exe



cd $* - Use cd with the argument given to the alias


cd $*


cd



^& - This uses the normal & for two commands with the ^ to as escape character


^&


&


^



dir -make an dir in the directory you just moved in


dir


dir



Additional info about doskey can be found here:


doskey



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.


doskey.exe



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.


conhost.exe


cmd.exe


python.exe


ReadFile


ReadConsole



This means you cannot pipe into an alias or use one in a batch script. For that you need a custom batch script.





Thanks that works a treat!
– Owen Jaques
Aug 22 at 14:11





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.
– eryksun
Aug 22 at 17:36


ReadFile


ReadConsole





@eryksun Thx for the add up. I will append this to the answer :)
– Paxz
Aug 22 at 17:38



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



How do I run two commands in one line in Windows CMD?






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế