Solved

script to check a folder and get all file size in subfolder

Posted on 2011-09-13
7
552 Views
Last Modified: 2012-05-12
Hi,

I need a script to get all file size (MB) in a specific folder and all subfolder.

the script must export to a csv file the result with all information like this:

Folder,filename,size

thanks
0
Comment
Question by:cawasaki
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Ryan Weaver
ID: 36528561
How about something like Get-DiskUsage by Joel Bennett
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 36528932
Do you want just one total for the specified folder, or a line for each subfolder as well?

~bp
0
 
LVL 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 36529069
Here's a starting place for you, save as a VBS and adjust the directory name at the top. It displays the results to the screen, but you can easily place into a file using redirection, as in:

cscript //nologo filesze.vbs > filesize.csv

sFolder = "c:\ee\temp"

Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

ShowFolderDetails oFS.GetFolder(sFolder)

Sub ShowFolderDetails(oFolder)
   For Each oFile in oFolder.Files
      Wscript.echo oFolder.Path & "," & oFile.Name & "," & Round(oFile.Size / 1024 / 1024, 2)
   Next
   For Each oSubFolder In oFolder.Subfolders
      ShowFolderDetails(oSubFolder)
   Next
End Sub

Open in new window

~bp
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:cawasaki
ID: 36529147
i need one line by file :)
0
 

Author Comment

by:cawasaki
ID: 36529158
hi Fryguy,

your link of powershell function is cool, can you explain me how i can use it? how i can add this function?

thanks
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 36529167
==> i need one line by file :)

Okay, that's what the VB script above does.

~bp
0
 

Author Closing Comment

by:cawasaki
ID: 36534993
thanks good its work perfectly
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now