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

dir /s works in mysterious ways :(

Discussion in 'Support' started by cxxl, Sep 13, 2017.

Tags:
  1. cxxl

    Joined:
    Aug 3, 2017
    Messages:
    10
    Likes Received:
    1
    Hi,

    I have a simple directory structure:

    I:\tmp> tree
    I:\tmp
    └──x
    ├──1
    │ ├──a
    │ └──b
    └──2

    If I enter "dir /sb" I get what I expect:

    I:\tmp> dir /sb
    I:\tmp\x
    I:\tmp\x\1
    I:\tmp\x\2
    I:\tmp\x\1\a
    I:\tmp\x\1\b

    But when I enter "dir /sb x", it doesn't display the whole depth of the tree:

    I:\tmp> dir /sb x
    I:\tmp\x\1
    I:\tmp\x\2

    When I use "dir /sb ." I get even less:

    I:\tmp> dir /sb .
    I:\tmp\x

    What am I not getting?

    TCC 21.01.46 x64 Windows 10 [Version 10.0.15063]
    TCC Build 46 Windows 10 Build 1506
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    Using TCC 21.01.49 (the current build), each of those commands in TCC returns exactly the same thing as CMD.

    The question is what results you actually want to return - if you just enter "x", then TCC (and CMD) will look for files named "x". If you enter "x*", they will look for a file or directory beginning with "x".
     
  3. cxxl

    Joined:
    Aug 3, 2017
    Messages:
    10
    Likes Received:
    1
    I would assume it works the same as without the "/s". If I enter "dir x", I get the contents of dir "x", not just all files named "x". I find the "/s" bevavior rather counter-intuitive. Plus, it's not even right: "dir /sb x" doesn't show me all the files named "x", see above.

    I just checked with CMD (Microsoft Windows [Version 10.0.15063]) and got this:

    I:\tmp> dir /s /b x
    I:\tmp\x\1
    I:\tmp\x\2
    I:\tmp\x\1\a
    I:\tmp\x\1\b

    It looks like I would like to get it, but TCC output is different.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    First, update to the current version (21.01.49) so we're comparing the same thing.

    This is what I get with TCC 21.01.49:

    Code:
    [F:\tmp]ver
    TCC  21.01.49 x64   Windows 10 [Version 10.0.16278]
    
    [F:\tmp]dir /s/b
    F:\tmp\x
    F:\tmp\x\1
    F:\tmp\x\2
    F:\tmp\x\1\a
    F:\tmp\x\1\b
    
    [F:\tmp]dir /s/b x
    F:\tmp\x\1
    F:\tmp\x\2
    F:\tmp\x\1\a
    F:\tmp\x\1\b
    
    [F:\tmp]cmd
    Microsoft Windows [Version 10.0.16278.1000]
    (c) 2017 Microsoft Corporation. All rights reserved.
    
    F:\tmp>dir /s /b x
    F:\tmp\x\1
    F:\tmp\x\2
    F:\tmp\x\1\a
    F:\tmp\x\1\b
    F:\tmp>
    
     
  5. cxxl

    Joined:
    Aug 3, 2017
    Messages:
    10
    Likes Received:
    1
    Lovely! Now it works. Thanks for the good support. :)
     

Share This Page