批量文件,返回文件夹大小 [英] Batch file that returns folder size

查看:121
本文介绍了批量文件,返回文件夹大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Vista机器上有空间问题,需要弄清楚占用太多的空间。



我想编写一个简单的批处理文件,返回C:下的所有文件夹以及每个文件夹的大小。



dir 命令似乎不会返回文件夹大小。



很抱歉,我们没有管理员权限,无法安装第三方应用程序,我们还有其他用户需要此信息。

解决方案

我将看一下这个线程,了解如何实现目录大小的一些线索:



显示目录大小的批处理文件



否则:



dirsize:

 code> @echo off 
setLocal EnableDelayedExpansion
set / a value = 0
set / a sum = 0
FOR / R%1 %% I IN(*) DO(
set / a value = %%〜zI / 1024
set / a sum =!sum!+!value!

@echo%CD%:!sum ! k

AllDirSize:

  echo off 
set WORKING_DIRECTORY =%cd%
for / fdelims =%% a in('dir / a:D / D / B / S')do
echo off
cd %% a
%WORKING_DIRECTORY%\dirsize%% a
cd%WORKING_DIRECTORY%

使用它: ALLDIRSIZE> C:\temp\FileContainingFolderSizes.txt



这是从优秀的Richard Bishop测试论坛取得的: http://www.bish.co.uk/forum/index.php?topic=58.0


I'm having space issues on my Vista machine and need to figure out what's taking up so much space.

I would like to write a simple batch file that returns all folders under C: and the size of each folder.

The dir command doesn't appear to return folder size.

Unfortunately we don't have admin rights and can't install a third party application and we have other users in our group that also need this information.

解决方案

I'd have a look at this thread for some clues as to how to achieve the directory size:

Batch File To Display Directory Size

Otherwise:

dirsize:

@echo off
setLocal EnableDelayedExpansion
set /a value=0
set /a sum=0
FOR /R %1 %%I IN (*) DO (
set /a value=%%~zI/1024
set /a sum=!sum!+!value!
)
@echo %CD%:!sum! k

AllDirSize:

echo off
set WORKING_DIRECTORY=%cd%
    for /f "delims=" %%a in ('dir /a:D /D /B /S') do (  
            echo off
            cd %%a
            "%WORKING_DIRECTORY%"\dirsize "%%a"
            cd %WORKING_DIRECTORY%
) 

Use it: ALLDIRSIZE > C:\temp\FileContainingFolderSizes.txt

Which is taken from the excellent Richard Bishop testing forums: http://www.bish.co.uk/forum/index.php?topic=58.0

这篇关于批量文件,返回文件夹大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆