script for calculating the files size...?

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
perich
Posts: 2
Joined: 2005-03-17 03:06:11

script for calculating the files size...?

Post 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
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post 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.

ScorEpioN
Posts: 264
Joined: 2004-08-17 11:02:02

Post 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
Guest

Post 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
ScorEpioN
Posts: 264
Joined: 2004-08-17 11:02:02

Post by ScorEpioN »

yes, there is no way to turn it back...
Guest

Post 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
perich
Posts: 2
Joined: 2005-03-17 03:06:11

Post by perich »

sorry, the upper answer was mine, forgot to log in :badidea:
Post Reply