Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
katragadda
Contributor II
Contributor II

Deleting the directories/files in folders/subfolders with exception of few files & Year wise

Hi All,

Good Morning..!!

We have requirement like deleting the qvw files in the folder structure with few of QVW files needs to excepted and keep the last 2 years files and rest of the old/Backup QVW files need to deleted.

folder structure :

1.Apps

            1.SE

                        AA (Folder Name)

                                    Backup (Folder Name)

                                                .qvw (files)                             

                        BB (Folder Name)

                                    Old(Folder Name)

                                                .qvw (files)     

                        CC (Folder Name)

                                    Backup(Folder Name)

                                                .qvw (files)     

            2.DK

            3.No

  

2.Data

3.Strings

4.Files

 

We have written the below script for deleting the QVW files in Old/Backup folders. 

sub DoDir (Root)

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

IF (WildMatch('$(Dir)', '*\Backup*', '*\OLD*')) THEN
TRACE Will remove $(Dir);
EXECUTE cmd.exe /C rmdir /s /q $(Dir);
ENDIF


Dir:
LOAD
'$(Dir)' as Dir
AutoGenerate(1)
;

call DoDir (Dir)
next Dir

end sub

 

call DoDir ('1.Apps')

Directories:
LOAD
*,
IF(WildMatch(Dir, '*Backup*', '*_OLD*'), 1, 0) as IsBackup
Resident Dir
;

DROP TABLE Dir;

1 Reply
Brett_Bleess
Former Employee
Former Employee

This is not really something QlikView is designed for, would likely recommend you use a PowerShell script and launch that via Publisher Support Task and External Program task to do the clean-up etc., that should be a much cleaner solution, but would allow you to control it from the Publisher side etc.  

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.