Link to home
Start Free TrialLog in
Avatar of solution1368
solution1368

asked on

window script

I have folder that contain many sub folders and many different type of files. like PDF, word,  excel, and etc.

I am looking for a software, script, or anything that I can get summary of file size, number of files of each file types.

like I want to see below

100 files, 200 GB PDF
200 files, 100 GB Word

And etc.

I can't do it one by one or sort in window explorer because it has many and many sub folders.

Thanks
Avatar of ampxvolt
ampxvolt
Flag of United States of America image

this product has done great by me!

treesize free at:

http://www.jam-software.com/freeware/

i liked it so much i bought a copy (which allows me to export data on the files i've found
Avatar of Happy Tohelp
This would work for doc files, copy and paste into notepad and save as a .ps1 file.
In powershell, navigate to the parent folder and run it.

Get-ChildItem -Recurse -fi *.doc | Measure-Object -Property length -Sum | FT "Word Docs",count, @{"Label"="Total Size(GB)";"Expression"={($_.Sum/1GB).tostring(0)}}

Attached is a ps1 with doc, pdf, xls included.  Change the .txt to .ps1 before you run it.
You can just open the txt file in notepad to review it also.

You can change to KB or MB instead, just change where it says 1GB to 1KB or whatever you like, and the TotalSize(GB) change GB to whatever you changed the other to.

Got some help from here and modified according to what you were asking.  HTH.
http://blogs.technet.com/b/heyscriptingguy/archive/2011/10/09/use-a-powershell-cmdlet-to-count-files-words-and-lines.aspx
count-and-list-file-size.txt
And treesize free from @ampxvolt is definitely awesome too. :)
I just took the opportunity to brush up on powershell.  Thanks for the question it was fun looking into PS again!
wait...off topic but TMekeel..that pshell script will find files?  do you mind if I take a copy to toy with it?
You can also look at Windirstat (also free)

http://windirstat.info/
http://windirstat.info/download.html
@ampxvolt--Feel free, that's what it's there for :)

It only aggregates the count (number of certain files) and then the sum of their sizes.

But I attached one that lists all the files but I dont think that is what the OP was after.

What do you mean by "find"?
It's a simple recursive search through the directories looking for *.doc etc.
This one lists the individual files and their sizes.
list-files.txt
Here's an AutoHotkey script that does what you requested:
#Warn
SetBatchLines,-1 ; run at maximum speed

BaseFolder:="c:\TestSummaryScriptInput\*.*"
ResultsFile:="c:\TestSummaryScriptOutput\Report.txt"

; first loop determines all of file types in the folder and
; initializes all of the Count and Size variables to zero
; and the OutputFlag variables to false
Loop %BaseFolder%,0,1
{
  Count_%A_LoopFileExt%:=0
  Size_%A_LoopFileExt%:=0
  OutputFlag_%A_LoopFileExt%:=false
}

; second loop counts each file type and adds up their sizes
Loop %BaseFolder%,0,1
{
  Count_%A_LoopFileExt%:=Count_%A_LoopFileExt%+1
  Size_%A_LoopFileExt%:=Size_%A_LoopFileExt%+A_LoopFileSizeMB
}

; third loop outputs the results
FileDelete,%ResultsFile%
Loop %BaseFolder%,0,1
{
  If OutputFlag_%A_LoopFileExt%
    Continue
  OutputFlag_%A_LoopFileExt%:=true
  OutputCount:=Count_%A_LoopFileExt% . " files, "
  OutputSize:=Size_%A_LoopFileExt% . " MB, "
  OutputType:=A_LoopFileExt
  FileAppend,%OutputCount%%OutputSize%%OutputType%`n,%ResultsFile%
}

MsgBox,0,Results Saved,Statistics from this run saved in`n%ResultsFile%

Open in new window

Change the BaseFolder variable at the top to be whatever your starting folder is (leave the *.* there) and change the ResultsFile variable on the next line to be whatever file you want for the results.

If you don't have AutoHotkey installed, download it (free!) from here:
http://www.autohotkey.com/

Copy my code above into a plain text file with whatever file name you want, but with a file type of AHK (for example, summary.ahk). Then just double click on the AHK file and it will run. The results file is a plain text file that looks like this:

15 files, 1717 MB, exe
4 files, 2 MB, jpg
47 files, 14 MB, pdf
5 files, 18 MB, txt
7 files, 30 MB, xls
3 files, 261 MB, avi
10 files, 10 MB, htm
9 files, 65 MB, swf

You don't have to tell the program what file types to find...it finds all of the file types in the base folder and all subfolders. It puts out the size in MB...divide the size by 1000 if you want GB. When it's done running, it shows this dialog:
User generated imageYou could make this a lot fancier, but it's a no-frills program that does what you want. Regards, Joe
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial