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

DoDir

Hi,

I have a qustion I hope I can get an answer for.

I have a map structure containg sub directories with old files. I want to to use DoDir but but wnat only the files from the directories bove the old files.

i.e.

Data

- New files

  - Old files

How can this be made?

//K

6 Replies
Gysbert_Wassenaar

Loop through the directories and check the directory name. Something like this:

sub ScanFolder(Root)

    for each SubDirectory in dirlist( Root & '\*' )

        if $(SubDirectory) <> 'Old files' then

            // do stuff

          call ScanFolder(SubDirectory)

        end if

    next SubDirectory

end sub

Call ScanFolder('D:\Data')


talk is cheap, supply exceeds demand
Miguel_Angel_Baeyens

Gysbert is correct, search the forums and you will find several examples like this one (of mine)

count files in folder

Miguel

Not applicable
Author

Hi and thx,

Problem is that my explanation of new and old folder was just a brief descriptin. The new folders has year naminf i.e. 2013, 2014, 2015 and so on and in those folder there may be several different sub folder with different names.

So I need a way where I jusr digg on level down regardles och names.

//K

Gysbert_Wassenaar

I'm sorry to say I'm beginning to understand less instead of more. Can you post an example of a directory structure with enough subdirectories to make clear all the conditions that should be applied when checking whether or not a subdirectory should be processed.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

An example:

Data

- Dir_1

   - File_1

   - SubDir_1

     - File_x

- Dir_2

   - File_2

   - SubDir_2

     - File_y

I want to grab the files in the first level of directories below Data dir. Thus, File_1 & File_2 but not what may be stored in SubDir_1 & SubDir_2 like File_x & File_y.

//K

Gysbert_Wassenaar

sub ScanFolder(Root)

    for each SubDirectory in dirlist( Root & '\*' )

        if $(SubDirectory) <> 'Old files' then

            // do stuff

           //  call ScanFolder(SubDirectory) <-- commented out to prevent recursively diving into the subdirectories

        end if

    next SubDirectory

end sub

Call ScanFolder('D:\Data');


talk is cheap, supply exceeds demand