Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 抑制与目录一起列出的目录名_Windows_Cmd - Fatal编程技术网

Windows 抑制与目录一起列出的目录名

Windows 抑制与目录一起列出的目录名,windows,cmd,Windows,Cmd,我想列出文件夹中的文件,但不想列出子文件夹中的文件DIR允许您列出特定类型的文件(隐藏、存档就绪等)以及仅列出文件夹,但我看不到如何仅列出文件 我需要下面的语句返回文件进行进一步处理,但是文件夹名称把事情搞砸了 for /f %%a in ('dir /b %csvPath%') do ( ) dir/b/a-d将为您提供没有目录的文件。注意/a-d之间没有空格。“-”表示“不是”目录 dir /b /s /a-d /p 从目录/?帮助信息: /A Displays f

我想列出文件夹中的文件,但不想列出子文件夹中的文件
DIR
允许您列出特定类型的文件(隐藏、存档就绪等)以及仅列出文件夹,但我看不到如何仅列出文件

我需要下面的语句返回文件进行进一步处理,但是文件夹名称把事情搞砸了

for /f %%a in ('dir /b %csvPath%') do (
)

dir/b/a-d
将为您提供没有目录的文件。注意
/a-d
之间没有空格。“-”表示“不是”目录

dir /b /s /a-d /p
目录/?
帮助信息:

  /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).
您可以使用:

dir /b /a-d
这将禁止列出目录

/A
开关有几个其他选项可帮助过滤:

/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 /显示具有指定属性的文件。 属性D目录R只读文件 H隐藏文件准备归档的文件 S系统文件I不是内容索引文件 L重新分析点-前缀的意思不是
使用
dir/B/A-D
仅获取文件。

您需要
/A-D
选项:

for /f %%a in ('dir /A-D /b %csvPath%') do ( )
/s
列出每个目录和包含文件的所有子目录,以及(a-d)不包含空目录

dir /b /s /a-d /p
/p
暂停

dir /b /s /a-d > list.txt

好极了我确实读了帮助文件,但那是在漫长的一天结束时!谢谢你指出这一点。我们也可以忽略结果中的文件扩展名吗?