Sorting (DIR) over sub-directories

May 30, 2008
235
2
Hi,

When you use DIR /O to sort the output it works so that it only sorts per sub-directory (assuming /S was included).

Is there some way to sort the total output over all sub-directories together?

For example, if you have a sub-directory tree and you want to use DIR /B /S to get a list of its contents for further processing, is there some easy way to get this list sorted by date&time for all files in the tree?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
nikbackm wrote:
| When you uses DIR /O to sort the output it works so that it only
| sorts per sub-directory (assuming /S was included).
|
| Is there some way to sort the total output over all sub-directories
| together?

I do it using PDIR, piping to the Windows utility SORT.EXE:

pdir/s/ou/(dy.m.d th.m.s z fpn) | sort

Hopefully, V11 will have an internal SORT utility to avoid piping.
--
Steve
 
May 20, 2008
603
0
Sammamish, WA
You could use ISO date format and pipe through sort, then extract just
the filenames.

This feature has been requested to be handled natively, but is not
currently supported. I can think of a few complications that make it
harder to support this way.

It may be that my timedir program at jcook.net/timedir will do what
you want. I wrote it to do much of what dir does, but I only support
the combined sorting and not the individual sorting that dir does. Try
timedir /s /b /o:d just as you would with dir.


Sent from Cookie's iPhone
Jim Cook

On Jun 17, 2009, at 5:58, nikbackm <> wrote:


> Hi,
>
> When you uses DIR /O to sort the output it works so that it only
> sorts per sub-directory (assuming /S was included).
>
> Is there some way to sort the total output over all sub-directories
> together?
>
> For example, if you have a sub-directory tree and you want to use
> DIR /B /S to get a list of its contents for further processing, is
> there some easy way to get this list sorted by date&time for all
> files in the tree?
>
>
>
>
 
May 30, 2008
235
2
nikbackm wrote:
I do it using PDIR, piping to the Windows utility SORT.EXE:

pdir/s/ou/(dy.m.d th.m.s z fpn) | sort

Thank you for the answer.

I already use this method to generate sorted listings, but it does not suit for what I had in mind since I want to have the file names only. Otherwise it would not be possible to use the output with e.g. @select for interactive selection and then further processing.

I could always pass it through another pipe after sort to remove the extra cruft of course, but I thought I'd see if there was an easier solution first.

It may be that my timedir program at jcook.net/timedir will do what
you want. I wrote it to do much of what dir does, but I only support
the combined sorting and not the individual sorting that dir does. Try
timedir /s /b /o:d just as you would with dir.

This seems to be just what I was looking for, I think I've heard about it before on these forums but could not remember exactly what it was.

Many thanks!
 
Similar threads
Thread starter Title Forum Replies Date
vefatica DIR sorting? Support 5
vefatica Sorting the global dir history Support 13
WavSlave DO not sorting as requested in v19 Support 11
M Sorting Files automatically Support 10
Joe Caverly Error when sorting list alphabetically for @select Support 2
A Bug report: Sorting modified in listview does not work Support 3
E Fixed Bug with DIR /Z displaying descriptions Support 8
J Paths shown in DIR /B Support 2
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
Jesse Heines How to? How to display picture creation date with dir command Support 6
vefatica WAD DIR.BTM? Support 11
DrusTheAxe DIR reports meaningless SYMLINK information Support 14
C show file description? with dir? Support 8
vefatica DIR /F and streams? Support 7
rps Multi-column DIR /v not displaying all files. Support 5
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
rps Dir /Nfv -> Alt-F2 Support 2
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
A TCMD - Dir Command puts out blank lines? Support 16
S Problems with dir command in the debugger Support 5
M TCC incorrect dir output since Windows 1803 Support 6
x13 Problem listing repository files using DIR http(s)://... Support 8
cxxl dir /s works in mysterious ways :( Support 4
vefatica Help nit (FFIND and DIR with /S) Support 0
N Fixed Strange dir behavior Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
C 7zip with date range .vs. filelist created with dir and daterange Support 0
D Towards shared (dir-)history lists Support 3
vefatica WAD DIR /HL still gets names wrong Support 16
vefatica DIR /S /HL? Support 4
H Fixed DIR /G returns wrong sizes Support 2
nickles WAD dir.htm Support 2
vefatica DO dir in /s /a:+d /d"g:\" * ( ... ) Support 26
vefatica DIR \\.\...? Support 4
M Fixed DIR /S /B1 ignores "/S" Support 5
C tcmd.ini not loading from program dir? Support 5
D Fixed Dir /Nm:n has changed Support 1
rps How to? dir /s unexpected results Support 10
vefatica Update to current install dir? Support 8
cgunhouse Problem with "dir /=" Support 4
T dir /h error in empty directory Support 22
P WAD TC 15.0.1.58 x64 crasches with a simple dir command Support 18
CWBillow dir /4 strange Support 2
samintz WAD DIR /B1 and /X Support 2
nickles dir behaves inconsistently Support 5
vefatica DIR, streams, and wildcards? Support 1
vefatica DIR /: /u ... streams not counted? Support 7
vefatica Documentation DIR /B /S /: Support 2
samintz How to? DIR listing for exact match Support 1
dcantor WAD dir "ftp:// ..." fails in TCC 15 Support 7

Similar threads