Re: make new alias -- weird behavior
Re: make new alias -- weird behavior
- Subject: Re: make new alias -- weird behavior
- From: Joel May <email@hidden>
- Date: Thu, 17 Feb 2011 09:19:13 -0600
Hey Axel,
The problem was that my computer was behaving strangely. I found 2 weird alias files in the root of my hard drive. I deleted them and the problem went away. I think the Finder did some weird caching that screwed things up. Or there are evil spirits in my computer.
Thanks for your help.
Joel
On Feb 15, 2011, at 10:38 AM, Axel Luttgens wrote:
> 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
_______________________________________________
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