Forum Discussion

Tris's avatar
Tris
Contributor
6 years ago

Delete a file based on date?

Hi all,

 

I've been looking for a way to manage files by deleting based on the files creation date.

 

I've seen the aqFile.GetCreationTime method, however this appears to want a specific file name.

 

Is there any way within test complete of finding files (more than one) based on their creation date in order to then use this information to delete them?

 

I have a feeling this might be something for a batch job to do, which will take a fraction of the time to do this way over the amount of time I've spent looking for a way to do this within TestComplete.

 

Many thanks.

Tris

  • Tris's avatar
    Tris
    Contributor

    FYI - I've manage to do exactly as I said I would try above, taken a matter of minutes via batch file.

     

    I made a batch file which TC will call and that will manage the files older than x days, see batchfile code below.

     

    ForFiles /p "C:\FOLDER" /d -14 /c "cmd /c del @file"

    /d sets the days value you are looking to delete, the example is going to delete anything older than 14 days

    /c is for the command string which deletes the files which are older than 14 days in the example above

     

    note, if you have sub-directories you want to clear out use /s like so... "C;FOLDER" /s 

     

    Note - still interested if my original question is possible, find TC is rather limited in a few ways and ideally want to keep as much of the functionality within the program if possible.