Move file after receiving via AirDrop

Howdy folks, I have a number of macros that use the Folder trigger which generally works well for files that are being downloaded. However, I recently added to my workflow sending a file to my iMac via AirDrop. The files that are received via AirDrop apparently are not handled in the same way as a file being downloaded from the Internet, which means the clauses "trigger all changes immediately", "ignore partial files" and "ignore partial or changing files" do not work properly.

Basically, if I try and use "trigger all changes immediately" Keyboard Maestro tries to move the file before it has finished being received and causes an error. If I use the other two clauses, it doesn't move the file at all. If I send another file after the first one, the first one is moved in the correct manner, but the second one is not.

Does anybody have any experience with using the Folder trigger with files transmitted via AirDrop and could tell me how to modify my macro for it to work properly please?

(I reposted this because in my original I messed up when trying to share the macro.)

If Then Else.kmactions (6.1 KB)

So I came up with a workaround that appears to work properly. Everything after the "Pause for 5 seconds" action is repeated one additional time, and in the handful of tests I've run it moves the file in question to the proper location.

Obviously this isn't the ideal solution so if anybody has other ideas I'd still be glad to hear them!

My initial workaround still didn't work 100%, so what I ended up doing was making another macro that would serve as the trigger, and using AppleScript it would enable my original macro whose trigger is now "periodically" and runs every 3 seconds. The trigger macro uses AppleScript to enable it, pauses for 20 seconds (to allow enough time for the now-enabled macro to see the file once it has been completely transferred via AirDrop), and the disables it again using AppleScript so it's not running every 3 seconds 24/7. Elegant? Not really. But it works like a charm.

Again, if anybody else has any other/better ideas, I'm all for hearing them.

Just ran into this issue myself and used a combination of things to resolve it.

  1. Set a Folder Trigger

  2. First action is a short Semaphore lock to prevent triggering after the first file is noticed in the trigger folder. Option to Cancel the macro is disabled.

  3. Execute a shell script to create of list of the files I'm interested in:
    find ~/Downloads/ -iname "*.jpg" -o -iname "*.heic" -ctime -1 -maxdepth 1
    although if you just want to recent files of any type, you could just use:
    find ~/Downloads/ -ctime -1 -maxdepth 1

  4. Cancel the macro if the file list is empty. (Downloads is the target for lots of other types of files.)

  5. Use a For Each on the file list to Move each file to the destination directory.

Haven't tested much but it seems to be doing what I want, which is trigger the macro once when any number of files are AirDropped to the Mac and move all of them to a different destination folder.

Maybe you can have it to trigger only after you can see the notification that file is successfully received.

The issue is that the Folder Trigger will trigger the macro for each file that is copied to the folder. So if you're AirDropping four files, the macro will be triggered four times.

The Semaphore lock prevents the macro from running more than one time.

(Then the issue becomes what to move out of Downloads. Which is handled by a filter.)