Dealing with duplicate drive names in /Volumes (Ext, Int)

Please bear with me, as I have been racking my brain on this. This is my last time before I give up and just cheat somewhere in my script. Ok, here goes:

If you have a firewire drive mounted, it creates an alias in /Volumes.

If you have an applescript that gets the contents of the folder /Volumes, it will list that alias, naturally.

If your startup disk has the same name as the FW drive, and your applescript uses the name of that FW alias, it will point to your startup disk, not the FW drive.

If you rename your startup disk, the alias again will point to the FW drive.

Applescript behaves this way because, when applescript returns the contents of /Volumes as text, the text can’t tell, later in the script, that there is a difference between one drive or another, even though they are in different locations, UNIX-wise.
Also, doing shell script “ls /Volumes” will also return the name as text, creating the same conflict.

Part of the problem is, the Finder shows all volumes in that weird directory “above” the hard drive (the one with the “computer name”), showing hard drive, mounted FW drives, and “Network”. This is not really the location of this stuff, on the UNIX level, but applescript is going by what the Finder sees.

So, in an applescript that can see the alias to the FW drive, it points to the startup drive if they have the same name because since 10.2, aliases try to resolve paths first, ID’s second, and because the name is the same as the alias, it resolves to the first path, in this case, the startup drive.

I know I could simply rename one of the drives, but for my project, I can’t really do that as I am setting up computers out of the box, and don’t want to rename people’s drives.

The only thing I can think of, is before the applescript runs, to rename startup disk temportarily, running the applescript, then naming it back. I can’t figure out how to rename the startup disk though, within an applescript.

I have seen other programs (like Bombich’s NetRestore and CCC) that exclude the startup disk from it’s routines, even if 2 disks have the same name. Not sure how he did this, but it could have something to do with “Alias Manager” and changing the way an alias resolves it’s original, by searching for ID first, path second.

Why, oh why, is it an alias in /Volumes and not the actual mount point? Where is the actual mount point for the firewire drive? When you do a show original on the alias, it shows the drive in that silly “My computer” directory (along with the startup disk and Network). So, in essence, according to the Finder, the hard drive is contained in a folder within itself. Very disturbing.

If anyone has any info on why this is like this, please share what you know. I can’t find much on apple developer. I think it’s simply something that is not possible using applescript.

ciao

What if you put something in the info:comments field of the Firewire drive. Is info:comments scriptable. Or maybe you could differentiate by size of the drives? I would just make a directory called Firewire and then delete it when i’m done. I use CCC and the Firewire or target boot disk is always the second one in the list, although i’ve never scripted anything for doing clones; both of my drives were the same but i could tell the difference between the 2 by where they were in the list of CCC.

Due to the issue that you are fighting, I think that most of the heavy lifting on this script is going to need to be handled in the shell, using AppleScript mainly for the GUI. I wonder if you can use some of the info returned by this.

set disk_info to do shell script "diskutil info /Volumes/'Macintosh HD'"

I also wonder if you could create and use a symlink (?) to the FW drive and then delete it when the copy is complete. I’m not a shell person, and symlink might not be the correct term, but I know that you are frustrated so I’m digging deep into the seldom used and poorly developed areas of my grey matter.

– Rob

Comments are scriptable but I think it isn’t necessary in this case. Something like the following might work if there was only one other drive named Macintosh HD.

set theHome to "remote folder"

tell application "Finder"
	close windows
	open folder theHome of folder "Users" of (get first disk whose startup is false and name is "Macintosh HD")
	duplicate items of window theHome to folder "Users" of startup disk
end tell

'Cept crunge had some permission problems when using the Finder to do the duplicating.

– Rob