Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to find out the size of a sub folder and a the main parent folder

Hi,

I found this macro for fidning the parent directory size but how should i find out the size of sub folders in the parent directory

Try with this macro

SUB DoDir (Root)

    FOR Each Ext in 'qvw', 'qva', 'qvo', 'qvs'

        FOR Each File in filelist (Root&' \*.' &Ext)

            LOAD

                '$(File)' as Name,

                FileSize( '$(File)' ) as Size,

                FileTime( '$(File)' ) as FileTime

            autogenerate 1;

        NEXT File

    NEXT Ext

    FOR Each Dir in dirlist (Root&' \*' )

        call DoDir (Dir)

    NEXT Dir

ENDSUB

CALL DoDir ('C:')

1 Solution

Accepted Solutions
engishfaque
Specialist III
Specialist III

Dear Tejaswini,

I'm sure you are looking for this one,

/*********************************************************************/

SUB GetFiles(vPath)

  For each vFile in FileList('$(vPath)\*.Q*')

  Files:

  Load

  '$(vPath)' as Folder,

  '$(vFile)' as File,

  FileSize('$(vFile)') As FileSize,

  FileTime('$(vFile)') As FileTime

  AutoGenerate(1);

  Next

End Sub

SUB GetSubFolders(vPath)

  For each vDir in DirList('$(vPath)\*')

  Folders:

  Load

  '$(vDir)' As Folder

  AutoGenerate(1);

  Call GetFiles('$(vDir)');

  Call GetSubFolders('$(vDir)');

  Next

End Sub

Call GetFiles('c:\Program Files\QlikView');

Call GetSubFolders('c:\Program Files\QlikView');

/*********************************************************************/

Reference: QlikView for Developers Cookbook by Stephen Redmond

Kind regards,

Ishfaque Ahmed

View solution in original post

4 Replies
engishfaque
Specialist III
Specialist III

Dear Tejaswini,

Please try this one,

SET vFileName    = 'C:\YourFileName.qvd';

LET vFileSize       = FileSize(vFileName);

TRACE FileSize:  $(vFileSize);

Reference link,

QlikTip #31: Access Qvd Meta Data programmatically without using QlikView but pure .net & C#

Kind regards,

Ishfaque Ahmed

jonathandienst
Partner - Champion III
Partner - Champion III

Amend your load statement like:

LOAD

  SubField('$(File)', '\', -1) as Name,

  '$(Root)' As Folder,

  FileSize( '$(File)' ) as Size,

  FileTime( '$(File)' ) as FileTime

autogenerate 1;

Now you have a field called Folder which you can use as a dimension with Sum(Size) as the expression.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Hi Jonathen,

this working out but i want the folders size to come out in the way like

parent folders in one field and suv parent folders in one field and the next field and so on

for example:

a->b->c->d

e->f->g->h

i->j->k->l

m->n->o->p

all the names a,e,i,m the main parents in one folder,

b,f,j,n in one field and so on c,g,k,o i another and d,h,l,p i ina nother field and their respective sizes.

engishfaque
Specialist III
Specialist III

Dear Tejaswini,

I'm sure you are looking for this one,

/*********************************************************************/

SUB GetFiles(vPath)

  For each vFile in FileList('$(vPath)\*.Q*')

  Files:

  Load

  '$(vPath)' as Folder,

  '$(vFile)' as File,

  FileSize('$(vFile)') As FileSize,

  FileTime('$(vFile)') As FileTime

  AutoGenerate(1);

  Next

End Sub

SUB GetSubFolders(vPath)

  For each vDir in DirList('$(vPath)\*')

  Folders:

  Load

  '$(vDir)' As Folder

  AutoGenerate(1);

  Call GetFiles('$(vDir)');

  Call GetSubFolders('$(vDir)');

  Next

End Sub

Call GetFiles('c:\Program Files\QlikView');

Call GetSubFolders('c:\Program Files\QlikView');

/*********************************************************************/

Reference: QlikView for Developers Cookbook by Stephen Redmond

Kind regards,

Ishfaque Ahmed