用 dir /s /b 输出全路径文件清单

CMD 经典的裸递归文件列表——所有批处理 for 循环期望的输入格式。

Windows文件命令提示符列表低风险
运行 dir <目录>\* /s /b,即可每行一个完整路径列出目录树中所有文件,无表头。

01命令

命令
$ dir C:\Proj\*.ps1 /s /b

02作用说明

/b(裸格式)去掉表头、大小列和汇总,与 /s 组合后每个结果都带完整路径——非常适合重定向到文本文件或用 for /f 逐行处理。加 /a:-d 可从输出中排除目录。当你只需要路径清单时,它往往比写 PowerShell 一行命令更快更简单。

03风险

风险低风险

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • dir | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    依据: Microsoft documents dir /s for subdirectories and /b for a bare list showing only file paths without headers or summaries.
  • DIR - Windows CMD
    SS64 · technical · 2026-09-17
    依据: SS64 notes /b strips headings and sizes leaving bare paths, and that /s /b output is ideal for feeding for-loops or redirection.

最后验证: 2026-09-17 · 分类: 文件与文件夹

06相关方案