If my startup disk is called “Macintosh HD” and a connected firewire drive is named “Macintosh HD”, how can I get applescript to differentiate them?
For example, if I am getting a list of disks, and I want to exclude the startup disk, it also excludes the other disk with the same name because “Macintosh HD” is a part of my exclude list (actually “startup disk” is part of my exclude list), and the script can’t tell that I only want to exclude the startup disk because it returns as text “Macintosh HD”.
Also, not sure if this is related, but why are the disks showing up as aliases within /Volumes? This never happened in Jaguar. Simply confusing.
As far as putting an empty file on one or the other, that may be possible, but it creates a possibility for error because theoretically, the connected firewire drive is a clone of the disk that I am on. Maybe I could have it reference something, if I get creative enough.
Rob, maybe I’m confused. But anyway, if I look in /Volumes and show original on the alias, it shows me my hard drive. If I drop my hard drive on a shell, I get /. If I drop the firewire drive on a shell i get /Volumes/Macintosh HD.
My problem is, because startup disk is returned as text, and has the same name as the firewire drive, there is a confilct.
Wouldn’t strtup disk = / and the firewire disk = /Volumes/firewiredisk? How is the startup disk an item of a directory within itself? Or is it an alias to startup disk? And if it’s an alias, that is what is causing the confilict. I think this problem is sort of an endless cycle, and having 2 drives with the same name is not ideal. I just wish there was a way to return a device ID or something.
I’m familiar with the problem that you are facing. Does this look like it would work?
set excluded_ to {"Network"}
set volumes_ to (path to startup disk as text) & "Volumes"
tell application "Finder"
try
set theList to name of items of alias volumes_ whose name is not in excluded_
on error
tell me to return display dialog "No disks available." buttons ¬
{"OK"} default button 1 with icon 1
end try
end tell
set theDisk to (choose from list theList with prompt "Please select a disk") as text
if theDisk = "false" then return
set excludedUsers to {"Shared"}
try
tell application "Finder" to set theUsers to name of (items of folder (theDisk & ":Users")) whose name is not in excludedUsers
on error
tell me to return display dialog "No home directories available" buttons ¬
{"OK"} default button 1 with icon 2
end try
set theHome to (choose from list theUsers with prompt "Please select a home directory") as text
set byteSize to size of (info for alias (theDisk & ":Users:" & theHome))
set size_ to convertByteSize from byteSize
set dd to (display dialog "The directory named '" & theHome & "' is " & size_ & ". Do you wish to continue?" buttons ¬
{"No", "Yes"} default button 2 with icon 1)
if button returned of dd is "No" then -- exit script
display dialog "You chose not to proceed - the script will now terminate."
return -- exit script
else -- proceed with duplication
display dialog "Stand by for duplication."
set source_ to quoted form of ("/Volumes/Macintosh HD/Users/" & theHome)
set shell_command to "ditto -rsrcFork " & source_ & " '/Users/student'"
do shell script shell_command
end if
to convertByteSize from byteSize -- by Nigel Garvey
if byteSize is greater than or equal to 1.099511627776E+12 then -- Terabytes (2 ^ 40)
((byteSize / 1.099511627776E+12 div 0.01 / 100.0) as string) & " TB"
else if byteSize is greater than or equal to 1.073741824E+9 then -- Gigabytes (2 ^ 30)
((byteSize / 1.073741824E+9 div 0.01 / 100.0) as string) & " GB"
else if byteSize is greater than or equal to 1048576 then -- Megabytes (2 ^ 20)
((byteSize / 1048576 div 0.01 / 100.0) as string) & " MB"
else if byteSize is greater than or equal to 1024 then -- Kilobytes (2 ^ 10)
((byteSize div 1024) as string) & " K"
else
(byteSize as string) & " bytes"
end if
end convertByteSize
Rob, that’s not doing it. I’m gonna repost this in a new thread, trying to make myself a little clearer, now that I understand a little more about what the heck is happening here.