CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-26-2011, 04:03 AM   #1
floopyb
Know-it-All
 
floopyb's Avatar
Jordan Walsh
Senior FX Artist
Iloura
Melbourne, Australia
 
Join Date: Nov 2004
Posts: 370
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-26-2011, 07:24 AM   #2
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,839
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-26-2011, 09:02 AM   #3
Track
Scholar
 
Track's Avatar
portfolio
Alexander Kramer
K-studio
Odessa, Ukraine
 
Join Date: Nov 2006
Posts: 49
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-26-2011, 11:04 PM   #4
floopyb
Know-it-All
 
floopyb's Avatar
Jordan Walsh
Senior FX Artist
Iloura
Melbourne, Australia
 
Join Date: Nov 2004
Posts: 370
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-27-2011, 06:55 PM   #5
Track
Scholar
 
Track's Avatar
portfolio
Alexander Kramer
K-studio
Odessa, Ukraine
 
Join Date: Nov 2006
Posts: 49
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-27-2011, 06:59 PM   #6
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,839
Looks really nice. Is this the same method used in windows explorer file properties?
 
Old 05-27-2011, 07:55 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,623
Send a message via ICQ to denisT
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-27-2011, 07:56 PM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,623
Send a message via ICQ to denisT
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-27-2011, 07:56 PM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:20 AM.


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