How to use the "dir >" command to get a very clean list?

Page 1 of 2 12 LastLast

  1. Posts : 133
    Windows 10 & Ubuntu Studio
       #1

    How to use the "dir >" command to get a very clean list?


    Hi there!
    I am getting "Access denied" with the following command line:

    dir > C:\Users\javie\OneDrive\Desktop /ad clean_list.txt

    What is wrong with the above command line?
    According to this page, I should be able to get a list of the directories ordered by name without the usual preceding columns for date, time, and <DIR> (01/23/2024 08:47 PM <DIR>).

    Thanks in advance guys!

    DPC
      My Computer


  2. Posts : 2,191
    Windows 10 Pro 64-bit v22H2
       #2

    For help with dir command type:
    Code:
    dir /?
    ">" is to direct the output. Put it right before the output file name.

    To only show the minimum use:
    /B Uses bare format (no heading information or summary).

    Here is an example using the corrected format. It will produce a list of directories in the directory C:\Users\javie\OneDrive\Desktop\ and write the output to the file clean_list.txt.

    Code:
    dir /ad /b C:\Users\javie\OneDrive\Desktop\ > clean_list.txt
    I did the following test using the following command:

    Code:
    D:\>dir /ad /b C:\Users\MisterEd\Desktop\ > clean_list.txt
    The contents of the file clean_list.txt was

    Code:
    Admiral Reply
    Downloads
    Games
    HPCUG
    MSI
    My Network
    Network
    OLLI & LQ 2023
    Programming
    Programs
    Raspberry Pi
    Screenshot
    SD Card
    Software
    Speakers
    TO ARCHIVE
    View Hidden Files
    Word Text  spacing
      My Computers


  3. Posts : 23,288
    Win 10 Home ♦♦♦19045.4355 (x64) [22H2]
       #3
      My Computer


  4. Posts : 133
    Windows 10 & Ubuntu Studio
    Thread Starter
       #4

    MisterEd said:
    For help with dir command type:
    Code:
    dir /?
    ">" is to direct the output. Put it right before the output file name.

    Word Text spacing[/CODE]
    This was soooo helpful, an eye-opener!

    Thank you MisterEd

    DPC

    - - - Updated - - -

    Oooh, nice! I love this utility!
    Thanks a bunch Ghot!

    DPC
      My Computer


  5. Posts : 23,288
    Win 10 Home ♦♦♦19045.4355 (x64) [22H2]
       #5

    drpeppercan said:
    Oooh, nice! I love this utility!
    Thanks a bunch Ghot!

    DPC


      My Computer


  6. Posts : 133
    Windows 10 & Ubuntu Studio
    Thread Starter
       #6

    MisterEd said:
    For help with dir command type:
    Code:
    dir /?
    Here is an example using the corrected format. It will produce a list of directories in the directory C:\Users\javie\OneDrive\Desktop\ and write the output to the file clean_list.txt.

    Code:
    dir /ad /b C:\Users\javie\OneDrive\Desktop\ > clean_list.txt
    I did the following test using the following command:

    Code:
    D:\>dir /ad /b C:\Users\MisterEd\Desktop\ > clean_list.txt
    MisterEd, your example couldn't have been clearer, and it made perfect sense.
    However, when I tried it, it did not yield the same results.
    I first tried it to save the txt file to the same directory, but it said it couldn't find the path specified.

    H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various>dir /ad /b H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various > Various_list.txt
    The system cannot find the path specified.

    Then I changed to the Desktop as in your example. But even though it did create the txt file, its contents were only: "GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}". Very unexpected.

    What do you think?
      My Computer


  7. Posts : 2,191
    Windows 10 Pro 64-bit v22H2
       #7

    I don't understand the syntax of your command. Did you mean for it to be?

    dir /ad /b H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various > Various_list.txt

    If you have a problem with that then put quotes around the path. For example,

    dir /ad /b "H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various" > Various_list.txt
      My Computers


  8. Posts : 133
    Windows 10 & Ubuntu Studio
    Thread Starter
       #8

    MisterEd said:
    I don't understand the syntax of your command. Did you mean for it to be?

    dir /ad /b H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various > Various_list.txt

    If you have a problem with that then put quotes around the path. For example,

    dir /ad /b "H:\BackUps\Manual Backups\Music\Rock, Pop, Progressive Rock, etc\Various" > Various_list.txt
    Unless you tell me otherwise, but as far as I can see the only difference between your command line and mine is that mine starts with the location of where I am at the moment when I am entering the command line (H:\BackUps\...), which is inside that same directory that I want to make the list of, and save the txt file in the same directory. I don't get why is it so hard.

    Even with the quotes still telling me that it cannot find such path, it makes no sense.
      My Computer


  9. Posts : 14,022
    Win10 Pro and Home, Win11 Pro and Home, Win7, Linux Mint
       #9

    I've always found it best to have a Command Prompt window open in the folder/directory where I want to work with getting a list of files such as C:\Users\NAMEHERE\ then at the prompt type dir>dir.txt. If no mistake the results won't be seen, just goes back to the prompt, but entering type dir.txt should bring up the file. This is an example of a USB drive I have plugged in, partial list:
    Attached Thumbnails Attached Thumbnails How to use the &quot;dir &gt;&quot; command to get a very clean list?-screenshot-2024-01-28-173006.png  
      My Computers


  10. Posts : 133
    Windows 10 & Ubuntu Studio
    Thread Starter
       #10

    Berton said:
    I've always found it best to have a Command Prompt window open in the folder/directory where I want to work with getting a list of files such as C:\Users\NAMEHERE\ then at the prompt type dir>dir.txt. If no mistake the results won't be seen, just goes back to the prompt, but entering type dir.txt should bring up the file. This is an example of a USB drive I have plugged in, partial list:
    This "C:\Users\NAMEHERE" does work for me. But "C:\Users\NAMEHERE>H:" Tells me access denied, even though I am running the Command Prompt as an Admin.

    Btw, obviously that I replaced "NAMEHERE" for "javie".
    Last edited by drpeppercan; 28 Jan 2024 at 21:32.
      My Computer


 

  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 05:50.
Find Us




Windows 10 Forums