Home > database >  How to delete all files in ~/Downloads that have not been touched, added, or opened in the last 30 d
How to delete all files in ~/Downloads that have not been touched, added, or opened in the last 30 d

Time:05-09

I'm trying to create an automator workflow or application that, when activated, deletes all the files and subfolders in my Downloads folder that have not been created, modified, added, opened, or accessed in any way in the last 30 days.

I tried filtering like this:

screenshot of automator

But that doesn't really do the job like I want it. First of all, there's no option to filter by "date added", which I would really like. Secondly, I would prefer it to prioritize a subfolder over that subfolder's contents. For example, I have a folder which I added today, but the file inside that folder has a "date added" of much longer ago. My preference would be that that folder, including its contents, are ignored and therefor not deleted.

screenshot of dates of example folder and files

Then I read in another stackoverflow thread (or it was at least some stackexchange site) that someone recommended to use a bash script instead. Something like this for example:

$ find "$HOME/Downloads" -type fd -mtime  30d -atime  30d -iname '*.*'

But even that doesn't seem to filter out the exact items that I want to filter out.

Can anyone help me out here?

  • Related