How to delete history Excel files (past four days)in the folder when I reload
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:
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);
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);