1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sorting (DIR) over sub-directories

Discussion in 'Support' started by nikbackm, Jun 17, 2009.

  1. nikbackm

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    1
    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?
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    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
     
  3. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    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:


     
  4. nikbackm

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    1
    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.

    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!
     

Share This Page