Page 1 of 1

script for calculating the files size...?

Posted: 2005-03-17 03:10:13
by perich
Hello!

i've been working With Ant for a long time now and love it. gets all the work done :)

My question, as it is said in the subject , regards files size. I've been importing file info for about 2 years now and my database has grown a bit :) My files size are represented in separate values (i.e. 650+650 MB) and i would like 2 convert them to a value that would say a sum(for upper example 1300 MB). Can that be done via some script, and if so, how?

Thanx and keep up the good work

Posted: 2005-03-17 09:08:29
by antp
Yes, it could be done with scripts easily:

Code: Select all

program CalcSum;
var
  i, Total: Integer;
  s: string;
begin
  i := 1;
  Total := 0;
  s := GetField(fieldSize);
  while i <= Length(s) do
  begin
    if (StrGet(s, i) >= '0') and (StrGet(s, i) <= '9') then
      i := i + 1
    else
    begin
      if i > 1 then
        Total := Total + StrToInt(Copy(s, 1, i - 1), 0);
      Delete(s, 1, i);
      i := 1;
    end;
  end;
  if i > 1 then
  begin
    Total := Total + StrToInt(Copy(s, 1, i - 1), 0);
    SetField(fieldSize, IntToStr(Total));
  end;
end.


Posted: 2005-03-17 12:03:24
by ScorEpioN
I inclued this fonction in my new UPDATE FIELDS version (v15)

UPDATE FIELDS V15 du 17/03/2005 *** DOWNLOAD ***

Format ''Somme'' pour la taille des fichiers (Sum Format to Size Field) : File size 700+500 -> 1200.

SCRIPTS POUR :

Image

Posted: 2005-03-17 12:57:22
by Guest
great, man, thanx... i dont know much about programming so those solutions are always a problem for me :))) but, i guess after i format size like that there is no way to turn it back like it was before? i mean, the file sizes are not memorized in any way to leave the vice versa formating possibility?

Thanx

Posted: 2005-03-17 13:01:57
by ScorEpioN
yes, there is no way to turn it back...

Posted: 2005-03-17 14:46:29
by Guest
maybe something like this is possible.... to calculate the sum value an present it in the following format:

Files Size: 1300 (650+650) MB

I guess this is possible, only problem after that would be to maybe choose the format of view when exporting to HTML for example. I guess this is pretty hard or even impossible cause there is no string like that in export builder (somethin like $$filesize_sum or $$filesize_nosum)... im just writting string examples cause im not in front of my own computer so i dont know them exactly.

Thanks

Posted: 2005-03-17 14:48:00
by perich
sorry, the upper answer was mine, forgot to log in :badidea: