Show folder sizes from a command prompt

General discussion related to "Everything".
Post Reply
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Show folder sizes from a command prompt

Post by void »

ES (Command line interface):
https://www.voidtools.com/support/everything/command_line_interface/

CalcFolderSize.bat

Code: Select all

rem SIZES OF USER FOLDERS
rem https://www.voidtools.com/downloads/#cli

CHCP 1251
SET "spaces=                               "
SET "delimiter=:"
SETLOCAL EnableDelayedExpansion
CLS
@echo off

REM uncomment to start Everything:
REM START Everything.exe -config Everything.ini -nodb -startup -monitor-pause
ECHO --------------------------------------
ECHO Folder sizes for %Username% in bytes:
ECHO --------------------------------------
SET "name=shell:Favorites"       && for /F "delims=" %%a in ('es.exe shell:"Favorites\" -get-total-size -timeout 60000') do (set size=%%a)      && CALL :formatout
SET "name=shell:My Pictures"     && for /F "delims=" %%a in ('es.exe shell:"My Pictures\" -get-total-size -timeout 60000') do (set size=%%a)    && CALL :formatout
SET "name=shell:My Music"        && for /F "delims=" %%a in ('es.exe shell:"My Music\" -get-total-size -timeout 60000') do (set size=%%a)       && CALL :formatout
SET "name=shell:My Video"        && for /F "delims=" %%a in ('es.exe shell:"My Video\" -get-total-size -timeout 60000') do (set size=%%a)       && CALL :formatout
SET "name=shell:Desktop"         && for /F "delims=" %%a in ('es.exe shell:Desktop\ -get-total-size -timeout 60000') do (set size=%%a)          && CALL :formatout
SET "name=shell:Personal"        && for /F "delims=" %%a in ('es.exe shell:Personal\ -get-total-size -timeout 60000') do (set size=%%a)         && CALL :formatout
SET "name=shell:Downloads"       && for /F "delims=" %%a in ('es.exe shell:Downloads\ -get-total-size -timeout 60000') do (set size=%%a)        && CALL :formatout
SET "name=shell:SavedGames"      && for /F "delims=" %%a in ('es.exe shell:SavedGames\ -get-total-size -timeout 60000') do (set size=%%a)       && CALL :formatout
SET "name=shell:Startup"         && for /F "delims=" %%a in ('es.exe shell:Startup\ -get-total-size -timeout 60000') do (set size=%%a)          && CALL :formatout
SET "name=shell:Common startup"  && for /F "delims=" %%a in ('es.exe shell:"Common startup\" -get-total-size -timeout 60000') do (set size=%%a) && CALL :formatout
SET "name=shell:NetHood"         && for /F "delims=" %%a in ('es.exe shell:NetHood -get-total-size -timeout 60000') do (set size=%%a)           && CALL :formatout
SET "name=shell:SendTo"          && for /F "delims=" %%a in ('es.exe shell:SendTo\ -get-total-size -timeout 60000') do (set size=%%a)           && CALL :formatout
SET "name=shell:Programs"        && for /F "delims=" %%a in ('es.exe shell:Programs\ -get-total-size -timeout 60000') do (set size=%%a)         && CALL :formatout
ECHO --------------------------------------
REM uncomment to exit Everything:
REM Everything.exe -exit
PAUSE
GOTO :EOF

:formatout
CALL :padright name 20
CALL :padleft size 13
ECHO %name% %delimiter% %size%
GOTO :eof

:padright
CALL SET padded=%%%1%%%spaces%
CALL SET %1=%%padded:~0,%2%%
GOTO :eof

:padleft
CALL SET padded=%spaces%%%%1%%
CALL SET %1=%%padded:~-%2%%
GOTO :eof
Example output:

Code: Select all

--------------------------------------
Folder sizes for User in bytes:
--------------------------------------
shell:Favorites      :          2714
shell:My Pictures    :       4964822
shell:My Music       :         32329
shell:My Video       :           504
shell:Desktop        :    4608845239
shell:Personal       :    1081536182
shell:Downloads      :             0
shell:SavedGames     :     967436427
shell:Startup        :          3903
shell:Common startup :           174
shell:NetHood        :             0
shell:SendTo         :          7538
shell:Programs       :         45688
--------------------------------------
therube
Posts: 5003
Joined: Thu Sep 03, 2009 6:48 pm

Re: Show folder sizes from a command prompt

Post by therube »

Just rambling...

Code: Select all

C:\USR\STEVEN\P\2P\X.COURTS>es.bat -get-total-size C:\USR\STEVEN\P\2P\X.COURTS\X
19824

C:\USR\STEVEN\P\2P\X.COURTS>es.bat -get-total-size -path .\x
17808

C:\USR\STEVEN\P\2P\X.COURTS>es.bat -get-total-size .\x
0

C:\USR\STEVEN\P\2P\X.COURTS\X>ss.bat -get-total-size
17808
es.bat:

Code: Select all

@es.ex2 -instance 15  %*
ss.bat:

Code: Select all

@es.ex2 -pause -sort name -highlight -path . %1 %2 %3   -instance 15

@if %errorlevel% NEQ 0 \bin\old\SS_old.bat *%1*
es.ex2 is es.exe.
I've just renamed it since I'm on 1.5, & it allows me to keep my batch file names the same (between 1.4 & 1.5)...

es.bat is simply a call to es.ex2 with an -instance.
ss.bat simply searches the current directory (tree) [using -path .].

Using shell:* like in 1st. example doesn't seem to work on my end (Win7)?

Code: Select all

C:\USR\STEVEN\P\2P\X.COURTS>es shell:Desktop\ -get-total-size
0
SpecialFoldersView:

Code: Select all

Folder Name 	Hidden 	Read Only 	System 	Folder Path 	CSIDL 	CSIDL Name 	Environment String Path
Desktop	No	Yes	No	E:\Users\RUBEN7\Desktop	0x10	CSIDL_DESKTOPDIRECTORY	%USERPROFILE%\Desktop 

-get-total-size, with a full path, returns (close to) the expected size?
-get-total-size, with a relative path, returns 0.

-get-total-size, along with -path, returns correct size (17808).


The disk space allocation of an NTFS volume may appear to be misreported for any of the following reasons:

The NTFS volume's cluster size is too large for the average-sized files that are stored there.
File attributes or NTFS permissions prevent Windows Explorer or a Windows command prompt from displaying or accessing files or folders.
The folder path exceeds 255 characters.
Folders or files contain invalid or reserved file names.
NTFS metafiles (such as the Master File Table) have grown, and you cannot de-allocate them.
Files or folders contain alternate data streams.
NTFS corruption causes free space to be reported as in use.
Other NTFS features may cause file-allocation confusion.
https://docs.microsoft.com/en-us/troubl ... fs-volumes
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Show folder sizes from a command prompt

Post by void »

Using shell:* like in 1st. example doesn't seem to work on my end (Win7)?
Everything 1.5 does not grant ES access to the shell: function.
es does not have enough privileges to expand shell: links.
I will allowing shell: access from ES in the next alpha update.



-get-total-size, with a full path, returns (close to) the expected size?
There might be another folder starting with E:\Users\RUBEN7\Desktop ?
Please try the following search:

es "E:\Users\RUBEN7\Desktop\" -get-total-size

(note the trailing slash in the path)
-get-total-size, with a relative path, returns 0.
This is expected, use -path .


Does anyone know a tool to expand shell:desktop from a command prompt?
Everything has:
es folder: shell:desktop -sort path -n 1
(this is pretty hacky).
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Show folder sizes from a command prompt

Post by NotNull »

void wrote: Thu Aug 26, 2021 7:25 am oes anyone know a tool to expand shell:desktop from a command prompt?
Everything has:
es folder: shell:desktop -sort path -n 1
(this is pretty hacky).
I was looking or that some time ago, but could not find anything (shell::::{guid}::{another guid} , etc. doesnt work)

However ..
After fixing calling shell: function from ES, wfn:shell:desktop should give the desired result (in Everything 1.5).
Last edited by void on Sat Aug 28, 2021 12:10 am, edited 2 times in total.
Reason: fixed :shell:
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Show folder sizes from a command prompt

Post by void »

:shell: == :shell: ... interesting..

Everything 1.5.0.1273a will now allow es to execute the shell: function.
therube
Posts: 5003
Joined: Thu Sep 03, 2009 6:48 pm

Re: Show folder sizes from a command prompt

Post by therube »

-get-total-size, with a full path, returns (close to) the expected size?
There might be another folder starting with E:\Users\RUBEN7\Desktop ?

Code: Select all

Microsoft Windows [Version 6.1.7601]

C:\BIN>es.bat -get-total-size C:\USR\STEVEN\P\2P\X.COURTS\X
19824

C:\BIN>es.bat -get-total-size C:\USR\STEVEN\P\2P\X.COURTS\X\
17808
So X\ is correct, but just what is happening there?
I certainly have other X directories, but not other full-path C:\USR\STEVEN\P\2P\X.COURTS\X.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Show folder sizes from a command prompt

Post by NotNull »

there might be a file- or foldername that *starts* with C:\USR\STEVEN\P\2P\X.COURTS\X, like:
C:\USR\STEVEN\P\2P\X.COURTS\X123.txt


Code: Select all

T:\>md folder

T:\>echo some text > folder\file.txt

T:\>es.exe t:\folder -gettotalsize
12

T:\>echo something else > folder123.txt

T:\>es.exe t:\folder
T:\folder
T:\folder\file.txt
T:\folder123.txt

T:\>es.exe t:\folder -gettotalsize
29

T:\>
therube
Posts: 5003
Joined: Thu Sep 03, 2009 6:48 pm

Re: Show folder sizes from a command prompt

Post by therube »

You've got it, thanks :-).

Code: Select all

C:\USR\STEVEN\P\2P\X.COURTS\XXX2   2,016
Post Reply