• 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: Axel Luttgens <email@hidden>
  • Date: Tue, 15 Feb 2011 17:38:22 +0100

Le 15 févr. 2011 à 15:04, Joel May a écrit :

> I need to programmatically create an alias file:
>
> /Library/Application Support/MyCompany/MyProduct/doodle.tag alias
>
> that points to
>
> /Applications/MyProduct/doodle/doodle.tag
>
> [...]
>
> 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:
>
> [...]
>
> 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?

Hello Joel,

I guess that you could go along those lines (more or less quickly tested here):

	set macSrcPath to POSIX file "/Applications/MyProduct/doodle/doodle.tag" as text
	set macDstFolder to POSIX file "/Library/Application Support/MyCompany/MyProduct/" as text
	set aliasName to "doodle.tag alias"
	set macAlias to macDstFolder & aliasName

	tell application "Finder"
		if exists file macAlias then
			set original item of file macAlias to file macSrcPath
		else
			make new alias at folder macDstFolder to file macSrcPath with properties {name:aliasName}
		end if
	end tell

That is: if the alias already exists, just ensure it  points to the correct item, otherwise create the alias.

HTH,
Axel

 _______________________________________________
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: make new alias -- weird behavior
      • From: Joel May <email@hidden>
    • Re: make new alias -- weird behavior
      • From: "email@hidden" <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