Automator Eject Action – OSStatus error -36

applescriptautomatorcatalina

Hopefully quick question:

I've made an automator quick action to eject all BUT the disks that are always hanging around my computer. It uses an AppleScript to get the list of disks, strip it of the local HD, "VM", "Home", and "Google Drive", since I don't need to eject those. I pass those to a shell script that just outputs each item after prepending "/Volumes/" to the name. This goes to an "Eject Disk" action, which is followed by a notification. The disks eject properly, but I get the OSStatus error -36, which causes it to stop after the eject action rather than display the notification and pop up an error. I can't find that error code via a google search – any ideas?

Error dialog:

Automator Error Dialog

Automator Script:

Automator Script

Best Answer

If you are going use AppleScript to get a list of disks you want ejected, then simply use, e.g.:

tell application "Finder" to eject cleanListOfDisks

Then there is no need to pass cleanListOfDisks to a Run Shell Script action to then pass it to a Eject Disk action.


Here is how I'd code the Run AppleScript action and not use any other actions:

set listOfDisks to list disks
set doNotEjectDiskList to {"Macintosh HD", "VM", "home", "net", "Google Drive"}
set listOfDisksToEject to {}

repeat with thisDisk in listOfDisks
    if thisDisk is not in doNotEjectDiskList then
        copy contents of thisDisk to end of listOfDisksToEject
    end if
end repeat

tell application "Finder" to eject listOfDisksToEject