Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Sorting (DIR) over sub-directories

May
238
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?
 
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
 
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?
>
>
>
>
 
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

Back
Top