批处理文件来显示目录大小 [英] Batch File To Display Directory Size
问题描述
大家好只是想知道如果u能帮助我修改此脚本,我一直都用打转转,我不能让它接受通配符charcters'*'
关闭@echo
SETLOCAL EnableDelayedExpansion
设置/值= 0
集/总和= 0
FOR / R%1 %% I IN(*)DO(
设置/值= %%〜紫/ 1024
集/总和=!总和!+!值!
)
@echo尺寸是:!总和! ķ
它在一个名为dirsize批处理文件,被称为像这样
dirsize C:\\文件夹
我想它来检查文件夹大小对我来说,这里这个是一个例子,在Firefox缓存
dirsize C:\\用户\\%USERNAME%\\ AppData的\\本地\\ Mozilla的\\火狐\\ *默认\\缓存
返回值0
但是,如果我去
dirsize C:\\用户\\%USERNAME%\\ AppData的\\本地\\ Mozilla的\\火狐\\ sr1znnb4.default \\缓存
它的工作原理,我获得价值55322 ..回来帮我好吗?谢谢你在前进好心人
的PowerShell使得这个容易,当然:
(GCI -Recurse |。测量物体长度,物业-sum).SUM
和PowerShell已经安装在Windows 7上获得的行列! : - )
此外, C:\\用户\\%USERNAME%\\ AppData的\\
是找不到应用程序数据的可靠方法。尝试%APPDATA%
(或 $ ENV:APPDATA
在PowerShell中)
Hi guys just wondering if u can help me modify this script that ive been playing around with, i cant get it to accept wildcard charcters '*'
@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 Size is: !sum! k
Its in a batch file called dirsize and is called like so
dirsize c:\folder
I want it to check folder sizes for me, this one here is an example, the cache in firefox
dirsize C:\users\%username%\AppData\Local\Mozilla\Firefox\*.default\Cache
Returns the value 0
But if I go
dirsize C:\users\%username%\AppData\Local\Mozilla\Firefox\sr1znnb4.default\Cache
It works and I get the value 55322 returned.. Help me please? Thank you in advance kind people
PowerShell makes this easy, of course:
(gci . -Recurse | Measure-Object -Property Length -Sum).Sum
And PowerShell is already installed on Windows 7. Get on the bandwagon! :-)
Also, C:\users\%USERNAME%\AppData\
isn't a reliable way of finding AppData. Try %APPDATA%
(or $env:APPDATA
in PowerShell).
这篇关于批处理文件来显示目录大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!