Dear Experts,
As the subject above, how to delete Excel history files(past four days)from the "test2" folder when I reload
Bellow is my macro and script:
![ASEDavidSu_0-1662968739604.png ASEDavidSu_0-1662968739604.png](https://community.qlik.com/t5/image/serverpage/image-id/88874i4BCB1657C709F668/image-size/medium?v=v2&px=400)
IF Date(FileTime(),'YYYY/MM/DD') = Date(Today(),'YYYY/MM/DD') OR Date(Today(),'YYYY/MM/DD')-1 OR Date(Today(),'YYYY/MM/DD')-2 OR Date(Today(),'YYYY/MM/DD')-3 OR Date(Today(),'YYYY/MM/DD')-4 then
QVDEVERYDAYDATAFiles:
LOAD [File Name],
QVDFileTime as noupdateFileTime,
FileSize,
Timestamp(DATE(qvdFileTime ,'YYYY/MM/DD PM hh:mm:ss'),'YYYY/MM/DD') as updateFileTime,
Timestamp(DATE(qvdFileTime ,'YYYY/MM/DD hh:mm:ss'),'YYYY/MM/DD hh:mm:ss') as UpdateFileTime
FROM
[D:\test2\*.xlsx]
(ooxml, embedded labels, table is QVDDATA);
ELSEIF Date(FileTime(),'YYYY/MM/DD') <> Date(Today(),'YYYY/MM/DD') OR Date(Today(),'YYYY/MM/DD')-1 OR Date(Today(),'YYYY/MM/DD')-2 OR Date(Today(),'YYYY/MM/DD')-3 OR Date(Today(),'YYYY/MM/DD')-4 then
let vxlsxfile = 'D:\test2\*.xlsx';
let filedeleted = (DeleteFile('$(vxlsxfile)')=-1);
TRACE File deleted $(filedeleted);
ENDIF
--------------------------------------------------------------------------------------------------------------------------------------------------------------
The macro was no problem and it can delete single file when I import the path but I can't find out all the files that was past 4 days ago and delete it.
let vxlsxfile = 'D:\test2\*.xlsx';
let filedeleted = (DeleteFile('$(vxlsxfile)')=-1);
TRACE File deleted $(filedeleted);
Please help me!!!
Thanks a lot!!