From: Clement Ow Date: 2008-07-07T17:47:07+09:00 Subject: Re: Getting Folder Size Pe単a, Botp wrote: > From: clement.ow@asia.bnpparibas.com > # Thanks for all your input, guys, really helped me alot! I > # actually went > # along with the WIN32OLE method, which is totally sweet > # especially when > # you have so many options and lines of code is quite hard to > # implement a > # recursive just calculate the file size(i also dont want to > # compromise on > # the efficiency of the script) =) Thanks once again! Really > # nice workin > # with you guys! =D > > interesting. imho, i find pure ruby's Find.find faster, more expressive, > shorter, and portable, eg, > >>dirsize =0 > >>Find.find("c:/ruby187") do |f| dirsize += File.stat(f).size end > #=> nil > >>dirsize > #=> 24569727 Hmm yea, this is quite an interesting way too, and more handy if you need to have more options like finding the size or dir count of the files in a certain directory. It is also easier to modify the code and get what you want eh? Thanks for the input botp! =) It has been a great learning experience so far! But just curious actually, that if there is any documentation that pertains to the win32ole methods, not the one from the ruby documentation of WIN32OLE but more of the methods that come along with it, not really sure how to explain but examples like these: folder = fso.GetFolder('C:\ruby\scripts') => # >> folder.name => "scripts" >> folder.size => 226746920 >> folder.path => "C:\\ruby\\scripts" so far I only know of GetFolder,GetFile, name, size, path kinda methods. just wondering if anyone knows if there is a list of such methods which might be really helpful in manipulating files and folders? Also, for fso = WIN32OLE.new('Scripting.FileSystemObject')is FileSystemObject part of ruby? The documentation in ruby states that: "The first argument should be CLSID or PROGID. If second argument host specified, then returns OLE Automation object on host." Does anyone know what this means? Thanks! -- Posted via http://www.ruby-forum.com/.