You are not logged in.

#1 19 Aug 2014 00:02

drifty
Member
Registered: 28 Nov 2007
Posts: 122

Folder Size with Robocopy

Is it possible to get a list of folders and their size using robocopy.
I have a drive with a hundred or so folders that i need to find the size of. Each folder has many su-folders but I only want the sum of the top level folders. I can do this with diruse but that is not possible in this case.

Offline

#2 19 Aug 2014 08:59

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Folder Size with Robocopy

It might take a while, but you could do something like this:

@echo off

if "%~1" EQU "" (set "root=%CD%") else (set "root=%1")

for /d %%D in ("%root%\*") do (
  for /f "usebackq tokens=2,3 delims=: " %%a in (`robocopy /l /s /nfl /ndl /njh "%%D" "%TEMP%\iMustNotExist%random%%random%" ^| findstr "\<Bytes\>"`) do (
    set /p "out=%%D is %%a" <nul
    if "%%a" NEQ "%%b" (echo: %%bbytes) ELSE (echo: bytes)
  )
)

Last edited by bluesxman (19 Aug 2014 09:20)


cmd | *sh | ruby | chef

Offline

#3 19 Aug 2014 19:28

drifty
Member
Registered: 28 Nov 2007
Posts: 122

Re: Folder Size with Robocopy

This works just like I wanted it to.
Thank you sir..

Offline

Board footer

Powered by