Announcement

Collapse
No announcement yet.

List of folder and thier size

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • List of folder and thier size

    Dear All,
    Kindly provide me a script to have a list of folders with the size. This is a shared folder in a server.
    This will help me to find which folder have more size and so i can remove unwanted data from the server.

    Thanks and answers are appriciated

  • #2
    Re: List of folder and thier size

    There's plenty of free scripts / programs on the web for this. Have you checked Google yet?
    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: List of folder and thier size

      Try WinDirStat http://windirstat.info/
      Caesar's cipher - 3

      ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

      SFX JNRS FC U6 MNGR

      Comment


      • #4
        Re: List of folder and thier size

        Hi Wired,
        I googled for the result but i cant find the results with folder size. only i get the list of folders and files.

        Hi L4andy,
        I need a script to export to text file for the list of folders with size. not a software.

        Thanks for the quick reply.
        But it will be more appreciated on getting the answer for this solution.

        Comment


        • #5
          Re: List of folder and thier size

          Hi,
          I got a VB script.

          Code:
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          Set objFolder = objFSO.GetFolder("C:\mov")
          Set colSubfolders = objFolder.Subfolders
          For Each objSubfolder in colSubfolders
              Wscript.Echo objSubfolder.Name, objSubfolder.Size
          Next
          But this is giving the size value in bytes. Can anybody modify this to make it in MB format
          Last edited by biggles77; 3rd November 2009, 11:01. Reason: Wrap text with CODE

          Comment


          • #6
            Re: List of folder and thier size

            If objSubfolder.Size is in bytes you just need to perform some math to make it different..

            bytesize = objSubfolder.Size
            kbsize = bytesize / 1024
            mbsize = kbsize / 1024

            Hobie

            Comment


            • #7
              Re: List of folder and thier size

              Dear Hobie,
              This doesn't works.
              Can you give me the complete script for the same.

              Thanks

              Comment


              • #8
                Re: List of folder and thier size

                I think he meant something like that:

                Code:
                 
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                Set objFolder = objFSO.GetFolder("C:\mov")
                Set colSubfolders = objFolder.Subfolders
                For Each objSubfolder in colSubfolders
                foldersize = objsubfolder.Size/1024/1024                           
                Wscript.Echo objSubfolder.Name, int(objSubfolder.Size/1024/1024) & "MB"
                Next
                However, folder sizes are not very accurate just aproximate. (Ie <1MB will show as 0)

                BTW, I thought you wanted to export it to a text file not message box!?
                Last edited by L4ndy; 3rd November 2009, 10:38. Reason: smelling pistake !!
                Caesar's cipher - 3

                ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

                SFX JNRS FC U6 MNGR

                Comment


                • #9
                  Re: List of folder and thier size

                  Originally posted by L4ndy View Post
                  BTW, I thought you wanted to export it to a text file not message box!?
                  If you run the script with a cscript command line you be able to redirect the output like,
                  cmd /c cscript.exe /nologo "c:\scripts\scriptname.vbs" > "c:\scripts\outputfile.txt"


                  Code:
                  wscript.echo now & vbNewLine
                  
                  Set objFSO = CreateObject("Scripting.FileSystemObject")
                  Set objParentFolder = objFSO.GetFolder("C:\mov")
                  
                  rem GetFolderSize objParentFolder
                  
                  For Each objSubfolder in objParentFolder.Subfolders
                     GetFolderSize objSubfolder
                  Next
                  
                  wscript.quit
                  
                  Sub GetFolderSize(Folder)
                     on Error Resume next: err.Clear
                     Dim lInt, aDecimalPlaces, strSize
                  
                     lInt = len(Folder.Size\1024)
                     If lInt =< 4 then
                       aDecimalPlaces = 1
                       strSize = FormatNumber(Round(_
                         Folder.Size/1024, aDecimalPlaces), aDecimalPlaces) & " KB"
                     ElseIf lInt =< 7 then
                       aDecimalPlaces = 2
                       strSize = FormatNumber(Round(_
                         Folder.Size/1024^2, aDecimalPlaces), aDecimalPlaces) & " MB"
                     ElseIf lInt > 7 then
                       aDecimalPlaces = 3
                       strSize = FormatNumber(Round(_
                         Folder.Size/1024^3, aDecimalPlaces), aDecimalPlaces) & " GB"
                     End If
                  
                     If err.Number <>0 Then
                       strSize = "<no access>"
                       err.Clear
                     End If
                  
                     wscript.echo Folder.Path & vbNewLine & _
                                 "size:", strSize & vbNewLine & _
                                 "files:", Folder.Files.Count & vbNewLine & _
                                 "subfolders:", Folder.Subfolders.count  & vbNewLine
                  
                     strSize = "<..>"
                  
                     rem for each subfolder in Folder.Subfolders
                     rem     GetFolderSize subfolder
                     rem next
                  
                  End Sub
                  \Rems

                  This posting is provided "AS IS" with no warranties, and confers no rights.

                  __________________

                  ** Remember to give credit where credit's due **
                  and leave Reputation Points for meaningful posts

                  Comment

                  Working...
                  X