Suppress directory names being listed with DIR

前端 未结 5 1024
攒了一身酷
攒了一身酷 2020-12-30 01:38

I want to list the files in a folder but not sub-folders. DIR enables you to list specific types of files (hidden, archive ready etc) and also only folders but

相关标签:
5条回答
  • 2020-12-30 02:10

    Use dir /B /A-D to get files only.

    0 讨论(0)
  • 2020-12-30 02:17

    You want the /A-D option:

    for /f %%a in ('dir /A-D /b %csvPath%') do ( )
    
    0 讨论(0)
  • 2020-12-30 02:21
    dir /b /s /a-d
    

    /s lists every directory and all subdirectories containing files, and (a-d) without empty directories.

    dir /b /s /a-d /p
    

    /p pause

    dir /b /s /a-d > list.txt
    
    0 讨论(0)
  • 2020-12-30 02:22

    dir /b /a-d will give you files without directories. Note there is no space between /a-d. The '-' says "NOT" directories.

    From the dir /? help information:

      /A          Displays files with specified attributes.
      attributes   D  Directories                R  Read-only files
                   H  Hidden files               A  Files ready for archiving
                   S  System files               -  Prefix meaning not
      /B          Uses bare format (no heading information or summary).
    
    0 讨论(0)
  • 2020-12-30 02:24

    You could use:

    dir /b /a-d
    

    Which will suppress directories being listed.

    The /A switch has a few other options to assist with filtering:

    /A          Displays files with specified attributes.
    attributes   D  Directories                R  Read-only files
                 H  Hidden files               A  Files ready for archiving
                 S  System files               I  Not content indexed files
                 L  Reparse Points             -  Prefix meaning not
    
    0 讨论(0)
提交回复
热议问题