Way to execute a AScript when a particular dmg is unmounted?

I’m totally new to applescript and am very interested in getting into it. My first question is from what I understand the Finder is very scriptable, so it there a way to execute a script when a particular dmg gets unmounted through the Finder? (both the trashbin and sidebar eject)

The dmg will be mounted with the ‘hdiutil mount image.dmg’ command. And then after it is ejected with the Finder I want it to execute another program or applescript but only execute when image.dmg is unmounted and not any other dmg file that might also be mounted.


This link shows how to attach a folder action tp the invisible Volumes folder. If you use the “items removed” Folder Action, you can have a script execute when a volume is ejected or removed.