-1

I am able to find all folders called "SS" (superseded) in a hierarchy and list out the location of each one.

I have been using this code to pipe out the list.

DIR /AD /B "SS" /S > SS_Folder_List.txt

How can I use either Powershell or the Command Line to take this list and return the total size of each folder?

2
  • What have you tried already? Where exactly are you getting stuck writing the script? Commented Aug 29, 2014 at 14:14
  • The above script works, I would like to know how to complete a further step. It returns a list of folders, how can I get the output to include the size of these listed folders?
    – RobN
    Commented Aug 29, 2014 at 15:11

2 Answers 2

1

You can do that in a single command:

for /d /r %%d in (ss.?) do dir "%%d" | Find "File(s)"

Some notes:

  • Your system needs to be in English, otherwise change File(s) to whatever your system outputs to the dir command
  • The for loop needs a wildcard, hence ss.? So, if you have folders called for instance ss.s these will also be included
  • If run from a command line, use %d instead of %%d
1
  • works brilliantly. I piped the output to a text file.
    – RobN
    Commented Sep 1, 2014 at 12:47
0

according to the first solution in How to list all folder with size via batch file your answer would be:

@echo off
setlocal disabledelayedexpansion

set "folder=ss%~1"
if not defined folder set "folder=%cd%"

for /d %%a in ("%folder%\*") do (
    set "size=0"
    for /f "tokens=3,5" %%b in ('dir /-c /a /w /s "%%~fa\*" 2^>nul ^| findstr /b /c:"  "') do if "%%~c"=="" set "size=%%~b"
    setlocal enabledelayedexpansion
    echo(%folder%\%%~nxa Size = !size!
    endlocal
)

endlocal

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .