Scheduled task to delete files in network drive's trashbox by size or delete date?

O

OsakaWebbie

Background: I have a Buffalo network drive that is used as a file server for two Win 10 Home PCs as well as for automated backups of my PC by Macrium Reflect. I only recently discovered that it has something similar to Windows' recycle bin called "trashbox", but run by the driver or something, not by Windows. (I can tell this because Shift-Delete does not skip the trashbox like it does for the recycle bin on the C drive.) When my backups are purged because new ones are made, those backup images are staying in the trashbox, so the drive eventually fills up, and other files also come and go, but don't really go. ;) It would be nice to automate some cleanup.


I could completely disable the trashbox feature in the Buffalo settings, but it's good protection against accidental deletion. What I'd like to do is delete from the trashbox any files that are larger than some size and/or have been deleted for some period of time.


I found helpful tutorials about deleting files using ForFiles in a scheduled task, but the only examples were based on a search mask on the filename (that would work for the old backups, but not other files) or date modified (which is not the date deleted - apparently moving a file to the trashbox does not change its date). Is there any way to programmatically tell when a file was sent to the trashbox folder, or its size? Also, the files in trashbox contain their complete path (parent folders all the way to the root), so it would be nice to also write a task/batch file to remove empty folders from trashbox - I don't know how to do that either.

Continue reading...
 
Back
Top Bottom