Wait for a Volume to Mount or Unmount/Eject in AppleScript
In working with Alfred, I've created a workflow that loads files from a Volume (DMG) file. In order for this to work correctly, I need the script to wait until the volume is actually loaded and visible in Finder before continuing. This can be done a few different ways, but here is the AppleScript code I'm using which works with Alfred or Keyboard Maestro. It's based on several examples I found. The first script gets the name of the mounted volumes and keeps looping until the expected volume shows up in the list. The second script is the opposite. It keeps looping and trying to eject the disk until the name isn't in the list of mounted volumes. Wait for Volume to be Mounted set mountedDisk1 to list disks set thevolume1 to "Insert Volume Name Here" set wasmounted to false set counter to 0 set max_number_of_iteration to 30 –activate –use activate to bring dialog to front if mountedDisk1 contains thevolume1 […]
Recent Comments