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

Recursively stop when certain folder created

Hello qlikers 🙂 ,

I'm saving all the qvds files in a certain folder. Please see the code below.

For example I'm in the folder Qlik/Test/App . In this app I want to save all the the .qvd files in the folder Qlik/Test/App/Backup . But when I'm saving the file in this folder, the method goes into the Backup folder.

How could I stop? I mean with that, when I saved all .qvd Files from the folder  Qlik/Test/App  and then he is  in the folder backup it should break up and goes to the next folder for example Qlik/Test/App2.

I hope you can help me! Thank you in advance!!! 

set vRoot = ['Qlik/Test/'];
set vStore = ['Qlik/Test/'];

sub GetQVDFIleNames(Root)

    for each FoundFile in filelist( Root & '\*.qvd') 
    
    let Namefile=PurgeChar(mid('$(FoundFile)',index('$(FoundFile)' ,'\',-1)+1),'.qvd');
    LET Test = SubField('$(Namefile)', '/', -1);
    LET ma = SubDirectory;
    	$(Test):
        	Load * from $(FoundFile) (qvd);
        	Store $(Test) into '$(ma)\Backup\$(Test).qvd' (qvd);
        	drop table $(Test);
    EXIT FOR WHEN '$(ma)\Backup' = '$(Namefile)'
    next FoundFile
    

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

        call GetQVDFIleNames(SubDirectory)

    next SubDirectory
    

end sub

Call GetQVDFIleNames($(vRoot))

 

 

Labels (3)
1 Solution

Accepted Solutions
Taoufiq_Zarra

can you try with this version :

set vRoot = ['Qlik/Test/'];
set vStore = ['Qlik/Test/'];

sub GetQVDFIleNames(Root)

    for each FoundFile in filelist( Root & '\*.qvd') 
    
    let Namefile=PurgeChar(mid('$(FoundFile)',index('$(FoundFile)' ,'\',-1)+1),'.qvd');
    LET Test = SubField('$(Namefile)', '/', -1);
    LET ma = SubDirectory;
        $(Test):
            Load * from $(FoundFile) (qvd);
            Store $(Test) into '$(ma)\Backup\$(Test).qvd' (qvd);
            drop table $(Test);
    next FoundFile
    

    for each SubDirectory in dirlist( Root & '\*' )
      let Namefile2=mid('$(SubDirectory)',index('$(SubDirectory)' ,'\',-1)+1);
      let flag=wildmatch('$(Namefile2)','*Backup*');
            if '$(flag)'<1 then
        call GetQVDFIleNames(SubDirectory)
            endif

    next SubDirectory
    

end sub

Call GetQVDFIleNames($(vRoot))
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

6 Replies
Taoufiq_Zarra

can you try with this version :

set vRoot = ['Qlik/Test/'];
set vStore = ['Qlik/Test/'];

sub GetQVDFIleNames(Root)

    for each FoundFile in filelist( Root & '\*.qvd') 
    
    let Namefile=PurgeChar(mid('$(FoundFile)',index('$(FoundFile)' ,'\',-1)+1),'.qvd');
    LET Test = SubField('$(Namefile)', '/', -1);
    LET ma = SubDirectory;
        $(Test):
            Load * from $(FoundFile) (qvd);
            Store $(Test) into '$(ma)\Backup\$(Test).qvd' (qvd);
            drop table $(Test);
    next FoundFile
    

    for each SubDirectory in dirlist( Root & '\*' )
      let Namefile2=mid('$(SubDirectory)',index('$(SubDirectory)' ,'\',-1)+1);
      let flag=wildmatch('$(Namefile2)','*Backup*');
            if '$(flag)'<1 then
        call GetQVDFIleNames(SubDirectory)
            endif

    next SubDirectory
    

end sub

Call GetQVDFIleNames($(vRoot))
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Anonymous
Not applicable
Author

Thank you very much! 

Unfortunately is not exactly what I need. 

This is my folder Structure

Unbenannasdsadt.PNG

In 'Versuch' there are subfolders for example Versuch/AI, Versuch/Reviews. In this Subfolders there are .qvd files.
I want to store all .qvd files from the subfolder Versuch/Reviews in the folder Versuch/Reviews/Backup. For the subfolder all .qvd files in the folder Versuch/AI/Backup.  But the subfolder Versuch/Reviews could have another subfolder Versuch/Reviews/Yesterday all .qvd files should be also saved in Versuch/Reviews/Backup.

My problem is when I'm trying to save all .qvd files from Versuch/Reviews  in Versuch/Reviews/Backup he also considered the Versuch/Reviews/Backup  folder. But he should skip only this folder Versuch/Reviews/Backup . 

Do you know what I mean with that? 🙂

Thank you in advance!! 🙂

 

Taoufiq_Zarra

Can you share a simple exemple the fullpath of folder and sub

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Anonymous
Not applicable
Author

Sure!

The Main path:

Qlik/Versuch

The Subfolders with files: 

Qlik/Versuch/Review
Qlik/Versuch/Review/test1.qvd
Qlik/Versuch/Review/test2.qvd
Qlik/Versuch/Review/Test/test3.qvd

Qlik/Versuch/AI
Qlik/Versuch/AI/test4.qvd

Qlik/Versuch/Service
Qlik/Versuch/Service/test5.qvd
Qlik/Versuch/Service/test6.qvd

.....

Where it should save Qlik/Versuch/PLACEHOLDER/Backup
Qlik/Versuch/Service/Backup, Qlik/Versuch/AI/Backup, Qlik/Review/Backup

I hope this will help you! 🙂

 

Taoufiq_Zarra

Steven,

the above script skip all subfolder with "*Backup*"

this what I understood, when you tested what is the result ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Anonymous
Not applicable
Author

The result is, that the script only writes on qvd in the last subfolder. 

Not in every subfolder, and only one .qvd! 🙂