Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Dec 15, 2017 3:27 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Folder Size
PostPosted: Mon Dec 14, 2009 9:01 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
I noticed that the GetFolderItem can return the count of items in its directly; however, I did not see anything that references folder size.

anyway to obtain the folder size of a folder?


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Mon Dec 14, 2009 10:02 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
yup... iterate thru the folder and add up the file sizes...

two problems

a) it needs to be recursive [if subfolders are involved]
b) .APP files on OSX are really "folders" and need to be processed as such [folderitem reports them as a file not a directory]

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Mon Dec 14, 2009 10:57 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
Ok... I can definitely do that.

my next question is, is it possible to to count all files and folders through a recursive scan?

meaning...

if this is my code
sub recurseFolder(startFolder As FolderItem)

Dim currentItem as FolderItem, itemCount as Integer

for itemCount = 1 to startFolder.item(itemCount)

currentItem = startFolder.item(itemCount)

if currentItem.Directory is true then
recursiveFolder(currentItem)
end if

next

end sub


Though I know I am not outputting the file names, I am more interested in the count. Looking at the code, whenever it comes across a directory it will call another instance of a recursive scan thus the count will start over.

I am not sure where to put the count.

anyway that I can store the count as a parameter?


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Tue Dec 15, 2009 12:57 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
This is recursion 101. Do a little reading. To get you started, you probably want something like
function recurseFolder(startFolder As FolderItem) as Integer


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Tue Dec 15, 2009 4:22 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
If you are interested in getting the size really fast, you need to avoid folderitems.

For example the DirectorySizeMBS does it very fast on Mac and Windows.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Tue Dec 15, 2009 9:17 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
Tim,

thank you for your input... I am still relatively new to programming and slowly gaining certain concepts. I was able to set a global property and use that as a means to keep track. Though I am not sure if this is the best way, it works for now. I will go ahead and research recursive scans.

Monkey,

I downloaded your plugins, however in the plugin folder, I did not see the DirectorySizeMBS. is it labelled something else?


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Wed Dec 16, 2009 2:36 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
DirectorySizeMBS is in the Util plugin and in the examples folder in the Util folder there is a project named "FolderSize.rbp" showing how it works.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 8:41 am 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
Monkey,

I downloaded and installed the plugin.

I am currently looking at the FolderSize app and I am very impressed with the speed. Currently, I am trying to figure out how to specify a custom folder.

I see under the PushButton3 section, you have:
f = SpecialFolder.System.CalculateDirectorySizeMBS


how can I specify a custom folder to get stats on?


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 9:05 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Well, the "specialFolder.System" tells which folder is used. So put here your folderitem variable for the folder.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 10:01 am 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
I tried it a few different ways...

bare with me... I am still grasping :)

soo.

if the code was
Dim f as folderItem
Dim d as DirectorySizeMBS

f = getfolderitem("c:\testfolder")

d = specialFolder.f


something like that? if so, it returns that no method exist


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 10:20 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Hi,
try something like this:

// chose a folder
dim f as FolderItem = SelectFolder

// calculate
dim d as DirectorySizeMBS = f.CalculateDirectorySizeMBS(True,0)

// display
MsgBox str(d.FilesCount)+" files in "+str(d.FolderCount)+" folder"


Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 12:17 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
ok.. that worked... but did make changes.

instead of a SelectFolder, I kept the getFolderItem

what I was missing was the (true,0) part.. However, what does this reference?


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 12:35 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
recursive: Whether to count items in the subfolders.
ticks: Whether to yield time to other threads. (See YieldTicks property)

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Dec 17, 2009 12:38 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
excellent...

I was playing around with the additional examples and can find great use for them.

Consider me a sold customer :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Folder Size
PostPosted: Thu Mar 07, 2013 8:23 am 
Offline

Joined: Thu Mar 17, 2011 6:12 pm
Posts: 73
Where can i get this plugin? Can someone please direct me via a URL link. Thanks: DirectorySizeMBS i've tried http://www.monkeybreadsoftware.de/realb ... gins.shtml but cannot figure out which one i need......


Cheers


Last edited by JayBird on Thu Mar 07, 2013 9:58 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group