quickest way to get file/directory sizes

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2011   #1
quickest way to get file/directory sizes

Is there a quicker way to get file sizes (talking tonnes of directories and Gigs of data) then just getFileSize?
__________________
Jordan Walsh
Senior FX artist

Showreel 2012
Check out my scripts at Script Spot!
 
Old 05 May 2011   #2
you could write a c# assembly but I doubt it will be much faster. Traversing all directories manually is the only way to get a total directory size.

Here is such an example:
http://madskristensen.net/post/Calc...ctory-in-C.aspx
 
Old 05 May 2011   #3
Quote:
Originally Posted by floopyb
Is there a quicker way to get file sizes (talking tonnes of directories and Gigs of data) then just getFileSize?


This is a most fastest way to get information about file.
http://www.pinvoke.net/default.aspx...dFirstFile.html
 
Old 05 May 2011   #4
Quote:
Originally Posted by Track
This is a most fastest way to get information about file.
http://www.pinvoke.net/default.aspx...dFirstFile.html


Could you give me a quick example of how to use that in maxscript, im not very good outside max!
__________________
Jordan Walsh
Senior FX artist

Showreel 2012
Check out my scripts at Script Spot!
 
Old 05 May 2011   #5
Win32_find_data

Quote:
Originally Posted by floopyb
Could you give me a quick example of how to use that in maxscript, im not very good outside max!


Code:
( fn CREATE_WIN32_FIND_DATA = ( if classof (dotnet.getType "FindDataEx.Kernel32")!=dotNetObject do ( local source=(dotNetClass "System.IO.File").ReadAllText @"YourPath\FindData_Example.cs" (dotNetClass "System.Text.Encoding").Default local csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider" compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters" compilerParams.ReferencedAssemblies.Add("System.dll"); compilerParams.ReferencedAssemblies.Add("System.Data.dll"); compilerParams.GenerateInMemory = on compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source) if compilerResults.errors.count == 0 then compilerResults.CompiledAssembly else for f in 0 to compilerResults.errors.count - 1 do ( print (compilerResults.errors.item[f].ErrorText) print ( compilerResults.errors.item[f].Line as string) ) ) ) CREATE_WIN32_FIND_DATA() -- (dotNetObject "FindDataEx.Kernel32").RecurseDirectory <System.String>directory <System.Int32>level [out]<System.Int32&>files [out]<System.Int32&>folders sst = timestamp() size = (dotNetObject "FindDataEx.Kernel32").RecurseDirectory @"D:\" (-1) &files &folders format "% GB |files: % |folders: %\n" ((size as float)/(1024^2*1024)) files folders format "Time: % sec\n" ((timestamp()-sst)/1000.0) )
Attached Files
File Type: zip CREATE_WIN32_FIND_DATA.zip (2.1 KB, 8 views)
 
Old 05 May 2011   #6
Looks really nice. Is this the same method used in windows explorer file properties?
 
Old 05 May 2011   #7
Quote:
Originally Posted by lo
Is this the same method used in windows explorer file properties?

as i know explorer uses something different and it's slow. Track's sample has to beat explorer, but it will be interesting to have comparison: max built-in getfilesize VS system.io.fileinfo VS kernel32 findfirstfile
 
Old 05 May 2011   #8
Quote:
Originally Posted by lo
Looks really nice. Is this the same method used in windows explorer file properties?

as i know explorer uses something different and it's slow. Track's sample has to beat explorer, but it will be interesting to have comparison: max built-in getfilesize VS system.io.fileinfo VS kernel32 findfirstfile
 
Old 05 May 2011   #9
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:12 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.