I wanted an Automator folder action to automatically remove old downloads from my downloads folder whenever I download a new file (I wanted to avoid making this a scheduled job).

The workflow looks like this: enter image description here

When I test it, it works fine - selecting only files older than 60 days. However when I actually download a new file to the downloads folder it sends the new file to the trash.

What gives? Is the timestamp on the new file not correct until after the download finishes or something?

EDIT: I discovered that it deletes the file being added to the folder no matter what. Meaning - if I drag and drop a new file to the folder, the workflow deletes it even though the time stamp is from today.

  • As an example, as a file is being downloaded in Safari, it has a .download extension appended and a date/time stamp of 01/24/1984 3:00 AM (at least on the East coast of the US). So, I'd try setting the Filter Finder Items action to | Find file where: All of the following are true | File extension is not .download | Date last opened is not in the last 60 days | and see if that makes any difference for you. Sep 6, 2017 at 15:30

3 Answers 3


Here is a solution to bypass Automator completely. Just save this script in the Script Editor.App to your /Users/your_shortname/Library/Workflows/Applications/Folder Actions folder. Once you do that, that folder action script will be available to choose from in your Services/Folder Acions Setup menu in Finder by control + click the downloads folder

This is the version if you are going to use Script Editor.app

on adding folder items to this_folder after receiving these_items
    tell application "Finder"
        set nameExtensionz to {"download"}
        set deleteFilez to items of (path to downloads folder) whose creation date < ((current date) - (days * 60)) and (name extension) is not in nameExtensionz
        delete deleteFilez
    end tell
end adding folder items to

If you do not feel comfortable with Script Editor app, in Automator app you can add a run AppleScript action and add my code. Just view the screenshot below. You will not need to worry about the new downloaded file getting deleted

This is the version to use if you are going to add an AppleScript action to an Automator Workflow folder action

tell application "Finder"
        set nameExtensionz to {"download"}
        set deleteFilez to items of (path to downloads folder) whose creation date < ((current date) - (days * 60)) and (name extension) is not in nameExtensionz
        delete deleteFilez
end tell

enter image description here

  • While this is a perfectly valid solution, the answer to "Why not?" is pretty simple: because we can't all write AppleScript, and that's the whole point of Automator ;)
    – calum_b
    Sep 6, 2017 at 16:55
  • Based on grgarside's answer, isn't this going to delete the file while it's downloading? (I haven't done any testing.) Sep 6, 2017 at 17:16
  • Just tested on Google Chrome and it waits until the download is finished. Works like a charm
    – wch1zpink
    Sep 6, 2017 at 18:16
  • 2
    @user3439894 My original code did not work using Safari. I just updated the code in my script and now it will not delete active downloading files. Now this works in Chrome and Safari
    – wch1zpink
    Sep 6, 2017 at 20:17
  • 1
    Your script works like a charm. I wish I knew exactly which automator action was going awry in my original attempt. The fact that I had a pause at the top of the script should have prevented it from deleting files as they were being created and waited until after the file existed to check its creation date. Sep 7, 2017 at 20:43

Finder uses the kMagicBusyCreationDate for files currently being downloaded, which is 08:34:56 on 1946-02-14 (+0000).

Use this date as a file's or folder's creation date to indicate that it is temporarily busy (while it is being downloaded or installed, for example).

What is the significance of 1946-02-14 08:34:56?

As this is well outside your date range, the file is removed immediately. Therefore you can’t use any date based checks whilst files are being downloaded.

  • I think this is the first time I've followed a link in a question to another question where I've ended up, up voting the question with the link as well as the linked question and its accepted answer. It was interesting reading! Sep 6, 2017 at 17:12
  • @user Thanks, that question was the first time I made hot network questions on SE!
    – grg
    Sep 6, 2017 at 17:14
  • @grgarside I just tested again by dragging and dropping a newly created file from my desktop to my downloads folder. The automator script deletes it even though the creation date is from today. Sep 6, 2017 at 18:33
  • @Paul The creation date whilst the file is being transferred is set to this too, so it’ll get deleted. ‘when copying or moving a file or folder using Finder; whilst the operation is in progress the destination file/folder is shown in grey. Finder is aware […] currently in an operation by setting the creation date of the file or folder to the kMagicBusyCreationDate’
    – grg
    Sep 6, 2017 at 18:52
  • @grgarside Okay - so I added a "Pause" command as the first step in the automator flow and have it pausing for 30 seconds (more than enough time for the copy operation to complete, its only a 1kb txt file). It's still deleting it. Not trying to be a pain, but this is really strange to me! Sep 6, 2017 at 18:55

No answer, but still bugged by this – "macOS bug".

While the significance of 1946-02-14 08:34:56 is truly an inspiring story, this does not seem to be the culprit of this issue at all. Using the workflow below I see the exact same behavior.

When I move a file from desktop into Downloads/ it is displayed with a "Date created" and "Date added" of today. I can see it there clearly in list view. BUT after the 10 s wait the file disappears – and it is obvious from stepping through the list that "Filter Finder Items" even after 10 s considers the file /old/.

Very odd bug.

Even more so, as the .download cannot be the culprit, because this precaution is not necessary at all if I create Automator workflow containing only the following Applescript code (based on @wch1zpink's code above but without the .download precaution) – which does work as expected (it does not delete the current/added file):

on run {input, parameters}

    tell application "Finder"
        set deleteFilez to items of (path to downloads folder) whose creation date < ((current date) - (days * 45)) and modification date < ((current date) - (days * 45))
        delete deleteFilez
    end tell

    return input
end run

I can also see (in the global macOS menu) the automator action only being run after a longer download is finished...

Workflow with initial uns election of added file and wait

  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – Allan
    Mar 31, 2020 at 22:45
  • My contribution does indeed not answer the question at all, it provides further details to an open question. I would have put it into a comment, which I however could not do (not enough kudos). Furthermore, to my mind the provided attempts at an answer seem incorrect or at least incomplete. Unfortunately, I do not know the answer to this problem and could not find it anywhere around the web.
    – yogik
    Apr 1, 2020 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .