Windows console ‘ls’ tip

I’ve been using the console a lot more on my windows machine here at blenderbox, and I find myself typing in the unix command ‘ls’ to display the directory listing over and over.  Each time I want to display the directory, I end up having to type in two commands.  I finally decided to do something about this today and created a batch file for ls to run the dir command.  To do this,

  1. Open a new text file, type: dir
  2. Save as ls.bat in C:\Windows\System32\

Now whenever I type ls by mistake, it runs the dir command, giving me the directory listing.  Sweet yea?

Comments

    Shaun |

    if you save “dir %1″ in the text file you can use commands like “ls *.exe” to list all exe files etc.

    BobG |

    just to expand a bit, if you save “dir %1 %2″
    you can pass options too
    you can use a command like “ls /b/p c:\windows”
    /b will give you a bare file list
    /p will pause the list if the list of files is too long for your console window
    It will also work with just “ls *.exe”

    Caleb |

    Nice tips guys.