I suggest to download utility DU from the Sysinternals Suite provided by Microsoft at this link usage: du [-c] [-l| -n| -v] [-u] [-q] -c Print output as CSV. -l Specify subdirectory depth of information (default is all levels). -n Do not recurse. -q Quiet (no banner). -u Count each instance of a hardlinked file. -v Show size (in KB) of intermediate directories. C: SysInternals>du -n d: temp Du v1.4 - report directory disk usage Copyright (C) 2005-2011 Mark Russinovich Sysinternals - www.sysinternals.com Files: 26 Directories: 14 Size: 28.873.005 bytes Size on disk: 29.024.256 bytes While you are at it, take a look at the other utilities. They are a life-saver for every Windows Professional. I guess this would only work if the directory is fairly static and its contents don't change between the execution of the two dir commands. Maybe a way to combine this into one command to avoid that, but this worked for my purpose (I didn't want the full listing; just the summary). GetDirSummary.bat Script: @echo off rem get total number of lines from dir output FOR /F 'delims='%%i IN ('dir /S%1 ^| find 'asdfasdfasdf' /C /V') DO set lineCount=%%i rem dir summary is always last 3 lines; calculate starting line of summary info set /a summaryStart='lineCount-3' rem now output just the last 3 lines dir /S%1| more +%summaryStart% Usage: GetDirSummary.bat c: temp Output: Total Files Listed: 22 File(s) 63,600 bytes 8 Dir(s) 104,350,330,880 bytes free. I solved similar problem. Some of methods in this page are slow and some are problematic in multilanguage environment (all suppose english). I found simple workaround using vbscript in cmd. The directory list, which resembles the tree view of the Windows Explorer but is sorted by file/subtree size, The treemap, which shows the whole contents of the directory tree straight away, The extension list, which serves as a. It is tested in W2012R2 and W7. >%TEMP% _SFSTMP$.VBS ECHO/Set objFSO = CreateObject('Scripting.FileSystemObject'):Set objFolder = objFSO.GetFolder(%1):WScript.Echo objFolder.Size FOR /F%%? ![]() IN ('CSCRIPT //NOLOGO%TEMP% _SFSTMP$.VBS') DO (SET 'S_=%%?' &&(DEL%TEMP% _SFSTMP$.VBS)) It set environment variable S_. You can, of course, change last line to directly display result to e.g. IN ('CSCRIPT //NOLOGO%TEMP% _SFSTMP$.VBS') DO (ECHO 'Size of%1 is%%?' &&(DEL%TEMP% _SFSTMP$.VBS)) You can use it as subroutine or as standlone cmd. Parameter is name of tested folder closed in quotes. ::Get a number of lines that Dir commands returns (/-c to eliminate number separators:.,) ['Tokens = 3' to look only at the third column of each line in Dir] FOR /F 'tokens=3'%%a IN ('dir /-c '%folderpath%') DO set /a i=!i!+1 Number of the penultimate line, where is the number of bytes of the sum of files: set /a line=%i%-1 Finally get the number of bytes in the penultimate line - 3rd column: set i=0 FOR /F 'tokens=3'%%a IN ('dir /-c '%folderpath%') DO ( set /a i=!i!+1 set bytes=%%a If!i!==%line% goto:size ):size echo%bytes% As it does not use word search it would not have language problems. Limitations: • Works only with folders of less than 2 GB (cmd does not handle numbers of more than 32 bits) • Does not read the number of bytes of the internal folders.
0 Комментарии
Оставить ответ. |
АвторНапишите что-нибудь о себе. Не надо ничего особенного, просто общие данные. Архивы
Март 2019
Категории |