Windows 10: dir Difficulties

  1.    25 Jun 2018 #1

    dir Difficulties


    I am seeking to sort files with dir.

    Creation date and time is my most primary interest.

    This has been my primary guide.
    MS-DOS dir command help

    I have tried a number of these commands in Powershell and Admin Powershell

    The simple one element wild card ones work okay. Ex
    dir *.exe

    All the others seem to use methods and techniques beyond my current skill level.

    First. I do not understand this statement.
    Options listed below may be preset in the DIRCMD environment variable. To override preset options, prefix any switch with - (hyphen), for example, "/-W".
    A description and example might help,


    The slash operator returns errors that I do not know how to fix. Ex
    PS G:\> dir /b
    dir : Cannot find path 'G:\b' because it does not exist.

    Why does PS reverse the direction of the slash?

    Any guidance, clearer examples,references,tutorials...will be appreciated.

    Thanks
      My ComputerSystem Spec

  2.    25 Jun 2018 #2

    You are using PowerShell (as indicated by the "PS" in the prompt). The PowerShell syntax is different from the "DOS" or CMD.EXE syntax that most people are familiar with.

    You can just run "cmd" in PowerShell to switch to CMD.EXE. If you want to use PowerShell you'll need to find PowerShell-specific references.

    Code:
    PS C:\temp> dir /b
    dir : Cannot find path 'C:\b' because it does not exist.
    At line:1 char:1
    + dir /b
    + ~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\b:String) [Get-ChildItem], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
    
    PS C:\temp> cmd
    Microsoft Windows [Version 10.0.17134.112]
    (c) 2018 Microsoft Corporation. All rights reserved.
    
    C:\temp>dir /b
    test
      My ComputerSystem Spec


  3. Posts : 925
    Windows 10 Home x64 and Pro x86
       26 Jun 2018 #3

    Mike,

    1 [error, deleted]

    2 You will get the most up-to-date definition of the command by entering dir /? once you have reached a Command prompt.

    3 Dir does not sort the files, it lists them. The SortOrder switch in Dir affects how they are listed on that occasion. You can also list files in your desired sort order within File explorer.

    4 You can get to a Command prompt window by several methods including that mentioned by PolarNettles. Another method is to use the Start menu where you will find a shortcut to open one in the Windows system group.

    5 You do not have to concern yourself with DirCmd if you do not want to. DirCmd is a variable that can be set up to have a desired value but is, by default, empty & has no effect.
    - I have never known anybody use DirCmd.
    - You will need to study the Set command & the whole subject of environmental variables to get to grips with DirCmd.
    - You can see a brief explanation together with some examples in Change Default Sorting Order of Dir - SuperUser.


    Denis
    Last edited by Try3; 26 Jun 2018 at 09:57.
      My ComputerSystem Spec

  4. Kari's Avatar
    Posts : 15,012
    Windows 10 Pro
       26 Jun 2018 #4

    Try3 said: View Post
    Dir does not use Creation date-time but LastModified date-time. I do not know of any ready-made tool that uses Creation date.
    DIR uses whatever time definition you tell it to use. Following command would list all files and folders in X:\Downloads in order they have been created:

    dir X:\Downloads /t:c


    Try3 said: View Post
    Dir does not sort the files, it lists them. The SortOrder switch in Dir affects how they are listed on that occasion. You can also list files in your desired sort order within File explorer.

    DIR is fully capable to sort files and folders. Following command would list all files in X:\Downloads, oldest first:

    dir X:\Downloads /o:d

    The minus sign before a parameter reverses the results, so the following command would list the same folder in reversed order, newest first:

    dir X:\Downloads /o:-d

    You can also combine switches. Following command would list all files and folders in X:\Downloads and all its subfolders (the /s switch), listing them in newest first based on time of file / folder creation:

    dir X:\Downloads /s /o:-d /t:c

    Kari
      My ComputerSystem Spec


  5. Posts : 925
    Windows 10 Home x64 and Pro x86
       26 Jun 2018 #5

    Kari,

    Thank you for your first point.

    About your second point, you are agreeing with the sentence of mine that you quote & that you appear to be taking issue with. Dir lists files and its lists can be displayed in several sort orders.

    Denis
      My ComputerSystem Spec

  6. Kari's Avatar
    Posts : 15,012
    Windows 10 Pro
       26 Jun 2018 #6

    Try3 said: View Post
    About your second point, you are agreeing with the sentence of mine that you quote & that you appear to be taking issue with.
    "Taking issue"? I was just correcting wrong information, a normal reply. No issues.

    That being said, no, I do not agree with you.

    Try3 said: View Post
    Dir does not sort the files, it lists them.
    Using correct parameters, DIR will sort files and folders it lists.

    Kari
      My ComputerSystem Spec


  7. Posts : 925
    Windows 10 Home x64 and Pro x86
       26 Jun 2018 #7

    Kari - We are both saying the same thing. Dir lists files and its lists can be sorted. Dir does not do anything to the files themselves but only to the lists it produces. Denis
      My ComputerSystem Spec

  8.    27 Jun 2018 #8

    I am getting the hang of this command set.

    Maybe somebody know a work around that will list the three time stamps at one time.
    Theoretically dir /TC /TA /TW.
    dir will only show one of the three at one time.

    To me it seems that the only way to get all three on a line is to run loop with output to file, then boiling down the three outputs to one line. Clumsy but maybe the only way to get the job done?

    Thanks for any suggestions.
      My ComputerSystem Spec


 

Related Threads
Macrium Reflect Difficulties in Backup and Restore
Hi all I've got an issue with imaging using Macrium Reflect Free. I'm running a dual boot system using Bootcamp with Windows 7 & 10 on two primary partitions on my iMac 24. Both work perfectly but if I run Macrium Reflect on either one of the two...
wifi settings difficulties in Network and Sharing
Symptoms: 1)Under one user account, wifi settings are not preserved. If I run ms-settings:network and select "Manage wifi settings", there is no choice for "Manage known networks". 2)Under a second user account, I cannot see wifi choices at...
Difficulties downloading Windows 10 in Installation and Upgrade
Hi all, I currently have Windows 8.1 and am looking to upgrade to Windows 10. I reserved a copy, and then got told it was ready to Download. I started the download and all seemed to be going fine for an hour. That was three days ago. Now, I...
I went from Windows 7 to Windows 10 yesterday. The upgrade went smoothly. But is it my imagination, or is everything now sitting on a brilliant white background? I'm getting eye-strain. Also, the new web browser (Edge, is it called?) has a...
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 06:52.
Find Us