# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

## DirList() and FileList()

Hi experts,

Can someone explain me haw these functions work and what is their syntax?  I am really confused how to use them, I looked at the reference manual and I tried something like this:

For each Ext in FileList('C:\Users\Gabika\Desktop\*.x*')

Main:

'\$(vFile)' as File

AutoGenerate (1);

Whatever I tried write in bracket, the result is still: c:\Program Files\QlikView\Themes\Wind.qvt

1 Solution

Accepted Solutions
Not applicable

## Re: DirList() and FileList()

Root is just a parameter of such sub, which defines where your search will start from. When you invoke this sub, you use C:\ as root, which means you will search those files from C:\ and its sub-folders.

7 Replies
Honored Contributor III

## Re: DirList() and FileList()

Find example from ref. manual.

// example 2 - list all QV related files on disk

sub DoDir (Root)

for each Ext in 'qvw','qvo','qvs','qvt','qvd'

for each File in filelist (Root&'\*.'&Ext)

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

end sub

call DoDir ('C:')

Vikas

Not applicable

## Re: DirList() and FileList()

I looked at it, but I do not understand it.   I need to explain it. Mainly I do not understand syntax in bracket.

Valued Contributor

## Re: DirList() and FileList()

Hi,

First we define the extensions we want to look for    for each Ext in 'qvw','qvo','qvs','qvt','qvd'

Then we define the directory we want to search, in this case (Root& and then we look for anything with one of the predefined extensions (see above) '\*.'&Ext)

So in this case we would search the computer for anything with these extensions 'qvw','qvo','qvs','qvt','qvd'

Not applicable

## Re: DirList() and FileList()

What does root mean? Where is it define?

Not applicable

## Re: DirList() and FileList()

Can someone explain me it ?

Thanks

Employee

## Re: DirList() and FileList()

Maybe this:

For each Ext in FileList('C:\Users\Gabika\Desktop\*.x*')

Main: