• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Resolving an alias
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resolving an alias


  • Subject: Re: Resolving an alias
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 30 Oct 2009 11:53:22 -0500

On Oct 30, 2009, at 11:12 AM, Emmanuel LEVY wrote:
We think it's better to work with posix paths rather than the native mac types for files.

(For those interested, the strong reason is that alias fails at making the difference between two mounted volumes or two shared volumes with the same name).

Mmmmm. I wondered. I was sure that aliases COULD distinguish between two volumes with the same name. An experiment is in order. Here's the script ...

on run
set test1 to alias "Work_Files:test-1.sparsebundle" -- disk name = "testDisk"
set test2 to alias "Work_Files:test-2.sparsebundle" -- disk name = "testDisk"
set test1disk to my mountImageDisk(test1)
set test2disk to my mountImageDisk(test2)
delay 3
tell application "Finder"
eject test1disk -- the CORRECT disk is ejected
end tell
end run

on mountImageDisk(imageFileAlias)
tell application "Finder"
set desktop shows external hard disks of Finder preferences to true -- so the icon is visible on the desktop
open imageFileAlias
end tell
set posixPath to (POSIX path of imageFileAlias)
if last character of posixPath is "/" then set posixPath to (text 1 thru -2 of posixPath)
repeat -- while Finder mounts the disk
try
delay 1
set imageInfo to (do shell script "hdiutil info")
set AppleScript's text item delimiters to {posixPath}
set imageInfo to (text item 3 of imageInfo)
set AppleScript's text item delimiters to {"/dev"}
set imageInfo to (text item 2 of imageInfo)
set AppleScript's text item delimiters to {tab & "/Volumes"}
set imageInfo to (text item 2 of imageInfo)
set AppleScript's text item delimiters to {return}
set volName to ("/Volumes" & (text item 1 of imageInfo))
exit repeat
end try
end repeat
set diskAlias to (POSIX file volName) as alias
do shell script "mdutil -i off " & (quoted form of (POSIX path of diskAlias))
return diskAlias -- an alias to the disk mounted from the disk image file
end mountImageDisk ------------------------------------------------------

And, the result is that aliases DO distinguish disks with the same name.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Resolving an alias
      • From: Emmanuel LEVY <email@hidden>
References: 
 >Resolving an alias (From: Thomas Fischer <email@hidden>)
 >Re: Resolving an alias (From: Sander Tekelenburg <email@hidden>)
 >Re: Resolving an alias (From: Thomas Fischer <email@hidden>)
 >Re: Resolving an alias (From: Emmanuel LEVY <email@hidden>)

  • Prev by Date: Re: Resolving an alias
  • Next by Date: Re: Unzip multiple items Applescript-terminal syntax help!
  • Previous by thread: Re: Resolving an alias
  • Next by thread: Re: Resolving an alias
  • Index(es):
    • Date
    • Thread