diff --git a/tdir b/tdir index 35483d9..cc74ddb 100755 --- a/tdir +++ b/tdir @@ -12,7 +12,7 @@ # Version info -VERSION = "$Id: tdir,v 1.62 2001/07/17 16:55:04 tundra Exp $" +VERSION = "$Id: tdir,v 1.63 2001/07/20 21:24:35 tundra Exp $" # Booleans @@ -35,6 +35,7 @@ RECURSE = FALSE # No recursion SHOWDIR = TRUE # Show directories in listing SHOWFILE = TRUE # Show files in listing +SORTBYEXT = TRUE # Sort file names by extension def OrderByExtension(list): @@ -86,19 +87,23 @@ DirList.sort() OutputColumns(DirList, TRUE) if len(FileList) > 0: - ExtList = OrderByExtension(FileList) - Ext = ExtList.keys() - Ext.sort() - for x in Ext: - FileList = ExtList[x] - if len(FileList) > 0: - FileList.sort() - if x == "": - sep = x - else: - sep = SEP - sys.stdout.write("{" + sep + x + "}\n") - OutputColumns(FileList, FALSE) + if SORTBYEXT: + ExtList = OrderByExtension(FileList) + Ext = ExtList.keys() + Ext.sort() + for x in Ext: + FileList = ExtList[x] + if len(FileList) > 0: + FileList.sort() + if x == "": + sep = x + else: + sep = SEP + sys.stdout.write("{" + sep + x + "}\n") + else: + FileList.sort() + OutputColumns(FileList, FALSE) + def BuildFileList (args, dir, files): @@ -125,6 +130,7 @@ ("-R", "Recurse down each named directory tree\n"), ("-c #", "Column width\n"), ("-d", "Do not display directories in output\n"), + ("-e", "Do not sort files by extension\n"), ("-f", "Do not display files in output\n"), ("-h", "Display this help information\n"), ("-s c", "Separator character\n"), @@ -144,7 +150,7 @@ # Program entry and command line processing try: - opts, args = getopt.getopt(sys.argv[1:], '-Rc:dfhs:tvw:') + opts, args = getopt.getopt(sys.argv[1:], '-Rc:edfhs:tvw:') except getopt.GetoptError: Usage() sys.exit(2) @@ -156,6 +162,8 @@ COLWIDTH = int(val) if opt == "-d": SHOWDIR = FALSE + if opt == "-e": + SORTBYEXT = FALSE if opt == "-f": SHOWFILE = FALSE if opt == "-h":