When I have multiple .DMG files open with the same name, then it seems like ‘path to me’ is not the path to the script, but the path to the first opend .DMG e.g. “/Volume/iVisualize Composition” instead of “/Volume/iVisualize Composition 1”
This is a bit of a problem, because I offer that .DMG as hull for other compositions to deliver their compostions in, so people that download more than one iTunes Quartz Composition at once (and most do) will have multiple Volumes with the same noame open (unless the composition author changed it).
The result is that only the first one get’s installed (several times :-).
Is there any way to correct this problem?
Thank you!
HFS path strings and Finder references cannot distinguish between drives with the same name. The only things that can are:
alias values (though obviously you can’t create them using HFS path strings; you can only use them if they come ready-made from apps or osaxen or by coercion from another file type)
POSIX file values (created using ‘POSIX file posix_path_string’)
POSIX path strings (obtained from various file values via their ‘POSIX path’ properties)
so you’ll need to modify your code to use those only.
This seems (to me) a bug in the Alias Manager (as you can observe this behaviour also in Finder aliases and the *nix side of the life -try, for instance, reproducing the behaviour and asking for PIDs using “ps -xww” and you will see there also the wrong path-, not only in the Standard Additions’ “path to me” command). I’d fire a bug report:
A quick workaround would include a “personalization” scheme (ie, create dmgs with unique names or include some kind of hardcoded name in your script’s code, or a identifier file in the same dmg, etc.). You should loop then (using the Finder) thru all matching same-name disks and locate this special file or blah, as the Finder is able to browse these “duplicate” volumes. Ie (no error trapping, etc., plain sample code):
tell application "Finder"
set x to modification date of every disk whose name contains "Blah" --> "Blah" = volume name
repeat with i in x
reveal (item "Blah.app" of (first disk whose modification date is i)) --> "Blah.app" = script name
end repeat
end tell