Re: make new alias -- weird behavior
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