Solved

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

Posted on 2011-09-13
563 Views
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
Question by:cawasaki
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3

LVL 4

Expert Comment

ID: 36528561
How about something like Get-DiskUsage by Joel Bennett
0

LVL 56

Expert Comment

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

~bp
0

LVL 56

Accepted Solution

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

~bp
0

Author Comment

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

Author Comment

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 56

Expert Comment

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

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

~bp
0

Author Closing Comment

ID: 36534993
thanks good its work perfectly
0

## Featured Post

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
###### Suggested Courses
Course of the Month11 days, 11 hours left to enroll