在 Windows 命令提示符中仅列出路径、文件名和大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16725517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:32:24  来源:igfitidea点击:

List only path, file name and size in Windows command prompt

windowscmd

提问by Jorge

In Windows command prompt, I'm trying to list only path, file name and size, of all files including in a folder and its sub folders. Like:

在 Windows 命令提示符下,我试图仅列出文件夹及其子文件夹中所有文件的路径、文件名和大小。喜欢:

dir /s /b /a-d "C:\MainFolder\"

Problem is that I don't know how to show size of file. Is it possible?

问题是我不知道如何显示文件的大小。是否可以?

回答by dbenham

From the command line:

从命令行:

for %F in ("c:\MainFolder\*") do @echo %~zF  %F

Double up the percents if you use the command in a batch file.

如果在批处理文件中使用该命令,则将百分比加倍。

Type HELP FORor FOR /?from the command prompt for more information on the various values that are available with FOR variable expansion.

在命令提示符下键入HELP FORFOR /?以获取有关 FOR 变量扩展可用的各种值的更多信息。

回答by Bal mukund kumar

Try this command ---

试试这个命令---

for %%a in (*) do echo %%a