Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 27
  1. #1
    Join Date
    May 2003
    Posts
    130

    Get the size of folder contents?

    Is there a way to do it without looping through all the files in the folder and checking individual file sizes?

    That method would be sufficent I suppose, but very slow for what I need to do.

    Any ideas on how this could be done in a different manner?


    ex: finding the total size of the program files folder and all of it's contents


    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Everything in Program Files and all subdirectories? Are you MAD? Do you want just the size of the directory or the size of the directory and a listbox that contains a list of all the files from all directories in Program Files?

  3. #3
    Join Date
    May 2003
    Posts
    130
    LOL, no I'm not mad


    Program Files was just an example. Maybe I wasn't clear enough.. what I'm trying to do is (example):

    Listbox:
    C:\Program Files (1504 mb)
    C:\Games (3440 mb)
    C:\Documents And Settings (250 mb)


    see what I'm saying? Just the absolute size of each folder I need to have searched.

    It's a little difficult to explain but i hope i did it better than before

  4. #4
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Merry Christmas!

  5. #5
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    I guess it helps if you actually include the attachment
    Attached Files

  6. #6
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    If you want an hourglass to show while the DLL
    gets the size, use this one instead of the one in
    the apz.
    Attached Files

  7. #7
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    beat out again :(

    Here I was trying to do it all within AMS5 . . . then again I don't know how to program .dlls so how else am I going to do it. Here is what I came up with.

    folder = Dialog.FolderBrowse("Please Select a Folder to get its current size", _DesktopFolder);
    folders = Folder.Find(folder, "*", true, nil);
    filesall = {};
    for fi,fv in folders do
    files = File.Find(fv, "*", true, true, nil);
    for filesi,filesv in files do
    Table.Insert(filesall, Table.Count(filesall)+1, filesv);
    end
    end
    fsize = 0;
    for i,d in filesall do
    size = File.GetSize(filesall[i]);
    fsize = fsize + size;
    end
    Paragraph.SetText("Paragraph1", "Your directory " .. folder .. " is " .. fsize .. " bytes in size.");

  8. #8
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Too cool Tig!

    I was going to try it in AMS, but didn't have the guts to try it. I'm not sure how well AMS would handle recursion to do sub-folders, but it seems it would work. I'd be interested in seeing the speed comparisons from LUA scripting to a DLLs speed. So, if you're bored ...

    I know from the little bit of testing I've done, the LUA script is rock solid and speedy.

  9. #9
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    Cool! Another free DLL from Worm. You are the greatest, thanks.
    Is there any chance that you could share the proper syntax for the calls in a text file so that those of us still using AMS4 could figure out how to use this DLL? You give so much, I’m sorry to ask for more, but it’s a nifty DLL, and I’d like a chance to use it too.

    Thanks again Worm.

  10. #10
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Here is some updated code. I ran into a couple of problems where I would get nil values in a table when I did the search. I have added a couple additional lines to detect this event and skip the section if detected.

    Worm, I will try some speed tests. With AMS it seems to be fairly speedy, but as the number of folders and files increase it starts to slow down. If you have suggestions on how to tighten up the code, let me know. I am always looking for ways to better my code.

    Here is the new code, just cut and paste into the button.
    Code:
    folder = Dialog.FolderBrowse("Please Select a Folder to get its current size", _DesktopFolder);
    StatusDlg.Show(MB_ICONNONE, false);
    if (folder ~= nil) and (folder ~= "CANCEL") then
    	folders = Folder.Find(folder, "*", true, nil);
    	if (folders ~= nil) then
    		filesall = {};
    		for fi,fv in folders do
    			files = File.Find(fv, "*", true, true, nil);
    			if (files ~= nil) then
    			 	for filesi,filesv in files do
    					Table.Insert(filesall, Table.Count(filesall)+1, filesv);
    				end
    			end
    		end
    		fsize = 0;
    		for i,d in filesall do
    			size = File.GetSize(filesall[i]);
    			fsize = fsize + size;
    		end
    		Paragraph.SetText("Paragraph1", "Your directory " .. folder .. " is " .. fsize .. " bytes in size.");
    		StatusDlg.Hide();
    	end
    end
    Last edited by TJ_Tigger; 12-04-2003 at 07:40 PM.

  11. #11
    Join Date
    May 2003
    Posts
    130
    Wow, thanks guys! Very helpful, as always

    Ill try it out and let you know!

  12. #12
    Join Date
    May 2003
    Posts
    130
    TJ: Your method seemed to work pretty well, but one problem.. the size returns completely inaccurate.. Screenshot attached :(



    Worm: I like the DLL, a lot. Although (a huge error on my part), the searching is not supposed to search in a whole tree, just the specified folder. (e.g. if theres 70 folders inside c:\winnt and 200 files, it would only return the size of the combined 200 files). I must have been sleeping when i described my question, very sorry!
    Attached Images

  13. #13
    Join Date
    May 2003
    Posts
    130
    Ahhh TJ, i figured out what was wrong.. had to change recurse to false for the file search, it was doubling the search.

  14. #14
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I realized that after playing with the file size stuff that I was omitting the files in the selected folder. I got all the folders under the selected but forgot the selected one. D'oh.

    Here it is for all to test. I have included Worms dll in here as well. I figured out how to make my code smaller. I don't know what I was thinking but it works well now with much smaller code.

    tigg
    Attached Files

  15. #15
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    Oops, I should have spent a little more time trying before I asked. With a little experimentation, I was able to figure out the function name and proper parameters for Worm's newest DLL. Thanks for the new tool Worm!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts