Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rxp03570
Creator
Creator

QVD Deletion from Script

Hi ,

As a part of my requirement I am generating QVD's for each month, but I just have to import previous 6 QVD's into my Application. Do we have any control to delete the QVD's which are greater than 6 months from today's date?.

Any possibility of house keeping process?.

Thanks,

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

You don't need to do it from Qlik at all - a single command in a cmd-file which can run each day is all you need:

delete-QVDs-older-than-180-days.cmd

ForFiles /p "C:\QVDFolder" /m *.QVD /d -180 /c "cmd /c del @file"

Use the Windows Task Scheduler to make the cmd-file run once a day....

You can find a detailed recipe here - ignore the first part about doing it manually with the File Explorer and skip down to the "Delete Files Older Than X Days with a Batch File" section:

     https://winaero.com/blog/delete-files-older-x-days/

View solution in original post

6 Replies
Anil_Babu_Samineni

Are you fine, If we can call Batch script?

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
rxp03570
Creator
Creator
Author

I think that should be fine, btw is that the only way?

petter
Partner - Champion III
Partner - Champion III

You don't need to do it from Qlik at all - a single command in a cmd-file which can run each day is all you need:

delete-QVDs-older-than-180-days.cmd

ForFiles /p "C:\QVDFolder" /m *.QVD /d -180 /c "cmd /c del @file"

Use the Windows Task Scheduler to make the cmd-file run once a day....

You can find a detailed recipe here - ignore the first part about doing it manually with the File Explorer and skip down to the "Delete Files Older Than X Days with a Batch File" section:

     https://winaero.com/blog/delete-files-older-x-days/

ManimekalaiS
Partner - Contributor
Partner - Contributor

Sub DeleteOldFiles (vPath,vNoOfDaysToKeep)
//Move file from C:\APPL Qlik\TestLog to C:\APPL Qlik\Logs\NPrintLog
// LET MoveCmd = 'MOVE $(vPath)"\*.qvd" "C:\APPL Qlik\Logs\NPrintLog\"';
// execute cmd.exe /c "$(MoveCmd)" ;
//Copy files from C:\APPL Qlik\TestLog to C:\APPL Qlik\Logs\NPrintLog
LET CopyCmd = 'COPY $(vPath)"\*.qvd" "C:\APPL Qlik\Logs\NPrintLog\"';
execute cmd.exe /c "$(CopyCmd)" ;
//Delete older 30 days files from C:\APPL Qlik\TestLog
LET DelCmd = 'forfiles /p $(vPath) /s /m *.qvd /d -$(vNoOfDaysToKeep) /c "cmd /c del @file"';
execute cmd.exe /c "$(DelCmd)" ;
End Sub;

Call DeleteOldFiles ('"C:\APPL Qlik\TestLog"',30);


/p Path The Path to search (default=current folder)
/m SrchMask Select files matching the specified search mask
default = *.*
/s Recurse into sub-folders
/c command The command to execute for each file.
/d date Select files with a last modified date greater than or

equal to (+), or less than or equal to (-),

the specified date, using the region specific date format

typically "MM/DD/yyyy" or "DD/MM/yyyy"