简体   繁体   English

在Windows cmd中获取一级项目的大小

[英]Get first level items size in Windows cmd

I want to list only the first level folders sizes of a giving folder. 我只想列出给定文件夹的第一级文件夹大小。 Dir /s will also display is going deep and displays dir command of all sub folders and files as well. Dir / s还将显示内容,并显示所有子文件夹和文件的dir命令。 But I need something like 但是我需要这样的东西

Dir FolderName

Resulting: 导致:

SubFlder1 1G, SubFolder2 2G etc. SubFlder1 1G,SubFolder2 2G等

Some details: 一些细节:

  • I am in the middle of reinstalling windows that went wrong, and the "old" system partition (c:) was deleted 我正在重新安装出错的Windows,并且删除了“旧”系统分区(c :)

  • I want to explore the "old" D: partition to backup data before continue 我想探索“旧的” D:分区以备份数据,然后再继续

  • Thus I can only use the Win10 installation command line utility (opened with shift+F10 in the activation code screen that is displayed at the beginning of the installation process), or of course any another utility available during installation. 因此,我只能使用Win10安装命令行实用程序(在安装过程开始时显示的激活码屏幕中以shift + F10打开),或者当然可以使用安装期间可用的任何其他实用程序。

Is it possible somehow? 有可能吗?

tx TX

To demonstrate my one liner, current directory is Q:\\Test 为了演示我的班轮,当前目录是Q:\\ Test

Q:\Test> tree 2017
Q:\TEST\2017
├───01
├───02
├───03
└───04

Q:\Test> For /d %A in (2017\*) do @Dir %A /A-D 2>Nul|find /V "/"|find /v "Dir("|find /V "Vol"

 Directory of Q:\Test\2017\01


 Directory of Q:\Test\2017\02

               2 File(s)        414.805 bytes

 Directory of Q:\Test\2017\04


 Directory of Q:\Test\2017\03

               1 File(s)            171 bytes

two issues with that 有两个问题

  1. The Dir parameter %A should be encapsulated in double quotes in case folder name contains space. 如果文件夹名称包含空格,则应将Dir参数%A封装在双引号中。 Took me a while to understand that. 花了我一段时间来理解这一点。
  2. It works only in case the folder tree has only one sub level. 仅在文件夹树只有一个子级别的情况下才起作用。 But when the sub folder contains folder(s) as well the folder size for that folder returns only the files within that specific folder, ignoring the sub folders items...Not sure the Dir approach fits here. 但是,当子文件夹包含文件夹以及该文件夹的文件夹大小时,仅返回该特定文件夹中的文件,而忽略子文件夹项...不确定Dir方法是否适合此处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM