Expire Files In A Folder: Delete Files After x Days

Posted by Brett G on Server Fault See other posts from Server Fault or by Brett G
Published on 2014-05-23T16:11:56Z Indexed on 2014/05/27 21:34 UTC
Read the original article Hit count: 167

I'm looking to make a "Drop Folder" in a windows shared drive that is accessible to everyone. I'd like files to be deleted automagically if they sit in the folder for more than X days.

However, it seems like all methods I've found to do this, use the last modified date, last access time, or creation date of a file.

I'm trying to make this a folder that a user can drop files in to share with somebody. If someone copies or moves files into here, I'd like the clock to start ticking at this point. However, the last modified date and creation date of a file will not be updated unless someone actually modifies the file. The last access time is updated too frequently... it seems that just opening a directory in windows explorer will update the last access time.

Anyone know of a solution to this? I'm thinking that cataloging the hash of files on a daily basis and then expiring files based on hashes older than a certain date might be a solution.... but taking hashes of files can be time consuming.

Any ideas would be greatly appreciated!

Note:
I've already looked at quite a lot of answers on here... looked into File Server Resource Monitor, powershell scripts, batch scripts, etc. They still use the last access time, last modified time or creation time... which, as described, do not fit the above needs.

© Server Fault or respective owner

Related posts about Windows

Related posts about windows-server-2003