• 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: make new alias -- weird behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make new alias -- weird behavior


  • Subject: Re: make new alias -- weird behavior
  • From: Jan Bultereys <email@hidden>
  • Date: Tue, 15 Feb 2011 16:43:21 +0100
  • Thread-topic: make new alias -- weird behavior

Title: Re: make new alias -- weird behavior
Hi Joel,

The fact that the alias is pointing to the source file (even in the trash) is normal behavior...

You should focus on recreating the alias (eg. Trashing it first)

This code should work (keeping in mind that the source file exist)

try
   do shell script "ln -s /Applications/MyProduct/doodle/doodle.tag  /Library/Application\\ Support/MyCompany/MyProduct/doodle.tag\\ alias"
on error number 1
    
do shell script "rm /Library/Application\\ Support/MyCompany/MyProduct/doodle.tag\\ alias"
    
do shell script "ln -s /Applications/MyProduct/doodle/doodle.tag  /Library/Application\\ Support/MyCompany/MyProduct/doodle.tag\\ alias"
end try

Best regards,jan




On 15/02/11 15:04, "Joel May" <email@hidden> wrote:

I need to programmatically create an alias file:

/Library/Application Support/MyCompany/MyProduct/doodle.tag alias

that points to

/Applications/MyProduct/doodle/doodle.tag

Using an alias makes it easy to redirect the doodle folder elsewhere.  I also like the robustness of aliases compared with symbolic links -- if the target folder is moved, the link usually survives.

We've used this mechanism in our product since OS8 and it's worked really well.  The alias is created during the install.  Until now, we've been using InstallerVise, but would like to move to PackageMaker.

The only way to create the alias is to use AppleScript talking with Finder.  

Here's the code:

tell application "Finder"
    set macSrcPath to POSIX file "/Applications/MyProduct/doodle/doodle.tag" as text
    set macDstFolder to POSIX file "/Library/Application Support/MyCompany/MyProduct" as text
    make new alias at folder (macDstFolder as text) to (macSrcPath as alias) with properties {name: "doodle.tag alias"}
end tell

This usually works, but it occasionally fails.  Here's what happens:

During development, I often drag a copy of the MyProduct folder to the trash and install a new copy.  If a copy of the product is in the trash, the above code will point the alias at the version of the file in the trash, not the one in the Applications folder.  In cmd-Info, Original is:

/Users/me/.Trash/MyProduct/doodle/doodle.tag

Of course, it should be:

/Applications/MyProduct/doodle/doodle.tag

I cannot figure out how to make it point to the correct file.  The above code specifies the path explicitly.  If I add

display alert macSrcPath

to the above code, it displays

Macintosh HD:Applications:MyProduct:doodle:doodle.tag

so the source variable is correct.

I've tried changing the last line to:

   make new alias at folder (macDstFolder as text) to (macSrcPath) with properties {name: "doodle.tag alias"}

(I removed 'as alias' after macSrcPath).  This made no difference.  Same weird behavior.

Of course, if I create the alias manually, it works fine.

If I empty the trash, it works fine.

Leaving this problem in the product will cause tech support headaches.   Does anyone know how to get 'make new alias' to always point to the file it is supposed to point to?

Thanks,
Joel May



_______________________________________________
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


 _______________________________________________
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

References: 
 >make new alias -- weird behavior (From: Joel May <email@hidden>)

  • Prev by Date: Re: make new alias -- weird behavior
  • Next by Date: Re: make new alias -- weird behavior
  • Previous by thread: Re: make new alias -- weird behavior
  • Next by thread: Re: make new alias -- weird behavior
  • Index(es):
    • Date
    • Thread