DIR output is backwards, any way to change it?

Dec 26, 2009
35
2
No where
The default output of DIR is:

Untitled-2.jpg

Just my opinion but this is completely backwards. The normal reading order is left to right. File names should be first, not last.

Is there any (easy) way to change this?
 
Here's one way of doing it, using PDIR and the FFIELDS command from the TextUtils plugin;
Code:
r:\>pdir /(f %@char[9] dy/m/d %@char[9] th:m:s %@char[9] zc) |! ffields
temp                   2022/04/22  13:34:29  <DIR>
01-amanwithaneed.mp3   2022/03/10  09:42:06  16,045,708
02-amaninthenight.mp3  2022/03/10  09:42:14  18,118,222
03-awomanatawell.mp3   2022/03/10  09:42:21  17,970,748
04-amaninthetombs.mp3  2022/03/10  09:42:27  19,380,782
05-amanupatree.mp3     2022/03/10  09:42:32  14,036,216
06-awomanwithajar.mp3  2022/03/10  09:42:37  14,939,150
odbc.exe               2014/09/30  14:16:29  33,792
results.htm            2022/04/17  13:31:11  15,500
screen.dat             2022/04/22  07:36:52  4,872
TRNSCTNS.DBF           2022/04/21  14:27:58  146,404
ws.dsn                 2022/04/21  14:28:10  255
zlb.txt                2022/04/17  13:43:27  5,918
...or as an alias...
Code:
r:\>alias myway=`pdir /(f %@char[9] dy/m/d %@char[9] th:m:s %@char[9] zc) |! ffields`

r:\>myway
temp                   2022/04/22  13:38:55  <DIR>
01-amanwithaneed.mp3   2022/03/10  09:42:06  16,045,708
02-amaninthenight.mp3  2022/03/10  09:42:14  18,118,222
03-awomanatawell.mp3   2022/03/10  09:42:21  17,970,748
04-amaninthetombs.mp3  2022/03/10  09:42:27  19,380,782
05-amanupatree.mp3     2022/03/10  09:42:32  14,036,216
06-awomanwithajar.mp3  2022/03/10  09:42:37  14,939,150
odbc.exe               2014/09/30  14:16:29  33,792
pdir                   2022/04/22  13:38:42  0
results.htm            2022/04/17  13:31:11  15,500
screen.dat             2022/04/22  07:36:52  4,872
TRNSCTNS.DBF           2022/04/21  14:27:58  146,404
ws.dsn                 2022/04/21  14:28:10  255
zlb.txt                2022/04/17  13:43:27  5,918

PDIR allows one to customize as desired.

Joe
 
Dec 26, 2009
35
2
No where
Here's one way of doing it, using PDIR and the FFIELDS command from the TextUtils plugin;
Code:
r:\>pdir /(f %@char[9] dy/m/d %@char[9] th:m:s %@char[9] zc) |! ffields
Well, PDIR does indeed work, and I can get the display output that I want ... sort of ... BUT ... only in very limited and very specific circumstances.

PDIR really only works, IF:
(1) All the filenames in a directory are more or less the same length
(2) Or, if there are longer filenames they are only at the top of the directory listing
(3) File names don't contain spaces

(Note that Joe's example matches #2 and #3.)

Otherwise, the output of PDIR (with or without | FFIELDS) is pretty much a mess.

It appears that I have accidentally discovered the real reason why TCC and CMD display directory contents backwards, with the filename last instead of first. Because the length of filenames can vary greatly, making it is extremely difficult to put the filename first and then get everything else (size, date, etc. ) to line up in nice neat columns. Maybe not impossible, but way too complicated.

Oh well, it was a learning experience. Thanks to everyone.
 
Dec 29, 2009
42
0
Atlanta, GA
If you want to be ambitious, you can write a BTM file that caches the file information in one or more arrays in memory, keeping track of the maximum filename width as you go, and then generates the output lined up accordingly.

15-20 years ago, I would have probably written it and posted it here.

With age, comes wisdom. I leave the actual implementation to the reader. :cool:
 
Aug 23, 2010
678
9
File names displayed last because
1. Filename length is an unknown factor.
2. Filename itself is an unknown factor.
If you would start your listing from filename, its content could potentially be confused with other data in the list. If you have filenames of varying length, you would either have the rest of the columns' content in random places across the screen, or if you align the next column by the maximum filename length, it may as well ride off-screen. Linux standard 'ls' tool also list file names last in the long formats. Do you think it is a coincidence?
 

Similar threads