Find folders called SS, return size of folder

-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?

BobJim

Posted 2014-08-29T13:27:02.030

Reputation: 980

What have you tried already? Where exactly are you getting stuck writing the script? – Ƭᴇcʜιᴇ007 – 2014-08-29T14:14:17.907

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? – BobJim – 2014-08-29T15:11:38.210

Answers

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

Berend

Posted 2014-08-29T13:27:02.030

Reputation: 1 824

works brilliantly. I piped the output to a text file. – BobJim – 2014-09-01T12:47:07.933

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

M. Abdelhafid

Posted 2014-08-29T13:27:02.030

Reputation: 282