"Mode" info returned by Windows 10 dir command

Page 1 of 2 12 LastLast

  1. Posts : 13
    Windows 10 Pro
       #1

    "Mode" info returned by Windows 10 dir command


    Windows 10 seems to have a new set of info returned by the "dir" Powershell command. This appears under the "Mode" heading, e.g. -a---- or d----- , but nowhere have I found what these entries mean or how to interpret the individual characters. I get that they have to do with folder and/or file permissions, but where are they explicitly described?

    TimDaniels
      My Computer

  2. Try3's Avatar
    Posts : 7,473
    Windows 10 Home x64 Version 20H2 Build 19042.928
       #2

    Folder/file "attributes" not permissions

    There is info about them in various places online such as
    Attrib - Edit file attributes SS64
    File Attribute Constants - Office 2013 - MSDN
    File Attribute Constants (Windows) - MSDN

    Denis
      My Computer

  3. Bree's Avatar
    Posts : 18,776
    10 Home x64 (20H2) (10 Pro on 2nd pc)
       #3

    This article explains mode in more detail...
    When you run a command the output includes a mode column:

    PS C:\work> dir *.txt

    Directory: C:\work

    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    -a--- 2/10/2012 8:21 AM 322158 a.txt
    -a--- 10/5/2011 8:37 PM 322174 a2.txt
    -a--- 2/15/2011 7:36 AM 5444 add-perm.txt


    Mode is actually showing the collection of file or folder attributes. But you can also get these attributes directly:

    PS C:\work> dir a*.txt | select Name,Attributes

    Name Attributes
    ---- ----------
    a.txt Archive
    a2.txt Archive
    ...
    File Attributes in PowerShell -- Microsoft Certified Professional Magazine Online
      My Computers


  4. Posts : 13
    Windows 10 Pro
    Thread Starter
       #4

    Neither your answer nor your links tell what d----- or -a---- means. The documentation of the FORMAT of the new "Modes" returned info is what I'm looking for. And this "Modes" info isn't returned by Windows 7, so it might be something new for Windows 10 and documentation may have been neglected.
      My Computer


  5. Posts : 13
    Windows 10 Pro
    Thread Starter
       #5

    Bree said:
    Thanks, Bree, that seems to imply that "Mode" is something new with Powershell, but that article also doesn't explain what each character POSITION represents in the Mode portion of the information. Nowhere have I been able to find that explanation.

    TimDaniels
      My Computer

  6. Try3's Avatar
    Posts : 7,473
    Windows 10 Home x64 Version 20H2 Build 19042.928
       #6

    A means archive bit is set
    D means directory [folder]
    R means read-only
    go to another folder for your dir cmd and you'll also find
    H hidden
    S system
    I not contents-indexed
    Correction [updated]: The 6th attribute shown is not the I attribute. It is L [Reparse point - such as a Junction point made using the mklink command].

    You can also see attributes explained by running the command attrib /?

    The only new aspect of this is that Powershell chooses to display file attributes under the heading Modes. There is nothing new about the attributes themselves.

    You can also see attributes in File explorer.

    The character positions mean nothing - Windows just decided to use this means of presentation of the data [again, this is not new but was simply not in this particular means of presentation before].

    Denis
    Last edited by Try3; 23 Nov 2018 at 12:35.
      My Computer

  7. Bree's Avatar
    Posts : 18,776
    10 Home x64 (20H2) (10 Pro on 2nd pc)
       #7

    TimDaniels said:
    Thanks, Bree, that seems to imply that "Mode" is something new with Powershell,...
    No, 'mode' has been a standard term for 'attributes' for a long time, such as in the unix command chmod (change mode). As far as I know Powershell has always shown them. There's a discussion (and a list of modes) on StackOverflow...

    Note that the mode you see is just a string representation of a bitfield enum...
    What are the possible 'Mode' values returned by Powershell's Get-ChildItem cmdlet? - Stack Overflow

    The bitfield is a sum of the individual values for each attribute, The full list of them and their meaning is here...

    FileAttributes Enum (System.IO) | Microsoft Docs
      My Computers


  8. Posts : 13
    Windows 10 Pro
    Thread Starter
       #8

    Try3 said:
    A means archive bit is set
    D means directory [folder]
    . . . .
    You can also see attributes explained by running the command attrib /?

    Denis
    Thanks for your replies, but the command "attrib /?" doesn't list the D attribute, much less the d attribute, or any other lower case letter. And there are many references to the term "file permissions" in Microsoft literature. Are "permissions" and "attributes" interchangeable terms in the Microsoft lexicon? Plus, "attrib /?" lists eleven upper case characters as settable attributes, but there are just 6 character positions alloted in the returned "Mode" information from the dir command. Are some of the 11 characters mutually exclusive so that a maximum of 6 characters makes sense?
    TimDaniels
      My Computer

  9. Try3's Avatar
    Posts : 7,473
    Windows 10 Home x64 Version 20H2 Build 19042.928
       #9

    Tim,

    No, "permissions" and "attributes" are not interchangeable terms. The things we are discussing are attributes.

    The case of the attribute makes no difference. A=a, D=d,

    PowerShell only makes 6 attributes visible in the dir results but many more exist. I listed the 6 but the links I gave you will give you further info about each one.
    Correction [updated]: The 6th attribute shown is not the I attribute. It is L [Reparse point - such as a Junction point made using the mklink command].

    Denis
    Last edited by Try3; 23 Nov 2018 at 12:36.
      My Computer


  10. Posts : 13
    Windows 10 Pro
    Thread Starter
       #10

    OK, Denis and Bree -

    So the returned info are just character strings representing bitwise sums of bit-position coded attributes. Thanks for bearing with me on this. Now the reason for the inquiry is because I'm trying to solve a BCD dual-booting problem - detailed in a subsequent question.
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 08:51.
Find Us




Windows 10 Forums