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

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
cawasakiAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
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
 
Ryan WeaverInfrastructure ManagerCommented:
How about something like Get-DiskUsage by Joel Bennett
0
 
Bill PrewCommented:
Do you want just one total for the specified folder, or a line for each subfolder as well?

~bp
0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
cawasakiAuthor Commented:
i need one line by file :)
0
 
cawasakiAuthor Commented:
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
 
Bill PrewCommented:
==> i need one line by file :)

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

~bp
0
 
cawasakiAuthor Commented:
thanks good its work perfectly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.