But there is a workaround, that is moving the file received by AirDrop from Download to your desired destination automatically as it is received. We can achieve this using a Folder Action combined with some filtering thanks to a security feature provided by Apple.
A Folder Action is an Automator workflow which runs whenever a file is added to a folder. Automator is a graphical programming environment specifically for macOS applications. It is similar to Shortcuts (originally Workflow) on iOS, but much older.
The finished Folder Action looks like this:
The Automator parts are hopefully straight forward. Simply search for the corresponding actions and drag them over.
- "Get Selected Finder Items" takes the files added to Download and feeds it to the
- "Run Shell Script" action, which filters to only the files transferred by AirDrop, and passes those to
- "Move Finder Items", where you can configure the destination of those files. I have added a new folder called "AirDrop" inside my Download folder for this purpose.
The shell script inside the "Run Shell Script" action needs a bit more explanation. The code is this:
for f in "$@" do if [[ -n $(xattr -p com.apple.quarantine $f | grep "sharingd") ]] then echo "$f" fi done
With "Pass input:" on the top right corner of the action as "as arguments", the for loop goes through each file. For each file, we check its
com.apple.quarantine extended attribute with
xattr and see whether
"sharingd" is contained in it. If so we
echo it, giving it to the next action to move, otherwise we ignore it.
The extended attributes (xattr) are extra metadata attached to files for various management purposes. In this case,
com.apple.quarantine is the xattr containing the quarantine level of a file and where it comes from.
sharingd is the daemon responsible for handling AirDrop on macOS, and it attaches this attribute with its own name in it to every file it receives. This is why we can use the command above to tell whether a file is received by AirDrop.
To test the Folder Action, I had to add a Get Specified Finder Items at the top, since I cannot use the actual folder event. Automator told me so when I clicked the Run button.
The shell script uses zsh, which is default for macOS Catalina.
If you like this post please press the like button to let me know! Please also comment to let me know what I can improve!
If you'd like to donate, please donate to Wikimedia Foundation, to which I owe infinitely.