![]() | Ned Batchelder : Blog | Code | Text | Site showfiles.py » Home : Code : Shell Utils |
Created 14 May 2002, last updated 24 November 2002 This is a replacement for 'dir'. I wrote it for one reason: I didn't see the point of using one command (dir) to see the names, sizes, and modification dates of files, and another command (attrib) to see the readonly (and other) attributes. So I wrote showfiles.py to do basic 'dir'-like things, but with the attribute bits displayed as well. The output looks pretty much like dir, but I've removed all of the excess noise (why on earth is the volume identification shown to me every time?), and made the output a little cleaner ("<DIR>"?). I've also sacrificed century for seconds (we live in a fast-paced world!), and added the attributes while making the output narrower: $ dir (For the detail-oriented: I've edited down the directory listings above, so the totals are wrong.) There are only a few options to showfiles: -d (or -od) sorts by date, and -s (or -os) sorts by size. The default is to sort by name. As you can see from the listings, it always shows all files, even those with the hidden or system attribute set. With no arguments, showfiles lists the files in the current directory. Arguments can either be files, directories, or standard wildcards. You can name as many of these in a single go as you want, all the results get shuffled together in the sort. The -r option makes showfiles work recursively on subdirectories. The sorting options are applied to the entire list of files, regardless of where in the tree they were found, and the path name (rather than just the file name) is shown. This recursive mode is implemented in a stupid inefficient way. I apologize. I don't actually type 'showfiles' at the command line. I use a doskey macro instead: doskey l=showfiles $* so I can just type 'l' (I like commonly-used commands to have short names). The main reason I still use "dir" occasionally is to list all files in a tree, but I'm planning to add that to showfiles as well. The last reason I still use "dir" (ironically) is for the extra bit of noise it always throws in: the space free on the disk. Download: showfiles.py | |
Comments
Add a comment: