1

In bash on Linux platforms, I can write an alias that performs a command, such as:

alias cdpics='cd /home/me/Pictures; ls -l'

Which will change to my Pictures folder and list its contents. And even use it to override commands:

alias sudo='echo;cd'

Which will make the sudo command echo what they pass to it, then change to their home holder. Is there a way to do this on the Windows command prompt - particularly the latter example? for instance, can I have the dir or tree command instead execute a batch file?

atom8bit
  • 86
  • 4
  • [`doskey` macros](https://superuser.com/q/1134368/380318) can override built-in commands - do those do what you're looking for? – Ben N Aug 11 '19 at 20:23

1 Answers1

1

Can I have the dir or tree command instead execute a batch file?

You can use doskey for this:

doskey dir c:\batch\mydir.cmd
doeskey tree c:\batch\mytree.cmd

See Doskey - recall commands - Windows CMD - SS64.com

DavidPostill
  • 153,128
  • 77
  • 353
  • 394