Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Exclude directories from a DirList

I have a very simple script loading every QVX file from all sub-directories of a directory.

directory;

for each dir_name in DirList('*')

    load * from $(dir_name)\*.qvx (qvx);

NEXT;

There are some sub-directories (for example 'bar','baz','foobar') I want to exclude from that DirList.

How would you go about it?

1 Solution

Accepted Solutions
Not applicable
Author

This is what worked for me. Note the single quotes around the sub-directory variable and sub-directories to be excluded.

Also I can use QvWorkPath because there is a "directory;" statement just before.

directory;

FOR Each dir_name in DirList('*')

IF  match('$(dir_name)','$(QvWorkPath)\bar','$(QvWorkPath)\baz','$(QvWorkPath)\foobar')= 0 then

    load * from $(dir_name)\*.qvx (qvx);

END IF;

NEXT;

View solution in original post

4 Replies
marcus_sommer

You will need a list of these directories which you want or which you not want - which one is shorter? Then you could use outside from your loop another loop or call these loop. Another possibility could be a if-loop inside your loop to check if these folder in your list or not.

- Marcus

Not applicable
Author

Isn't there a coding pattern on how to kick out list elements from a list?

This seems better style to me.

marcus_sommer

directory;

for each dir_name in DirList('*')

    if match($(dir_name), 'bar','baz','foobar') = 0 then

         load * from $(dir_name)\*.qvx (qvx);

     end if

NEXT;

Not applicable
Author

This is what worked for me. Note the single quotes around the sub-directory variable and sub-directories to be excluded.

Also I can use QvWorkPath because there is a "directory;" statement just before.

directory;

FOR Each dir_name in DirList('*')

IF  match('$(dir_name)','$(QvWorkPath)\bar','$(QvWorkPath)\baz','$(QvWorkPath)\foobar')= 0 then

    load * from $(dir_name)\*.qvx (qvx);

END IF;

NEXT;