Re: Say "What?"
Re: Say "What?"
- Subject: Re: Say "What?"
- From: Axel Luttgens <email@hidden>
- Date: Mon, 4 Jan 2010 23:53:53 +0100
Le 3 janv. 2010 à 17:56:45, Paul Skinner a écrit :
> So, the moral of this script is that Aliases aren't what I thought they were. I thought that they were references to the inode or some such, and didn't care about the file properties like names. Other than namespace collisions at the folders level that is. The solution seems to be to recreate the aliases as you modify the filenames. I had no idea that this was so. Has it always been so? 10.5.8 AS 2.0.1.
>
> [...]
Hello Paul,
Perhaps does your example illustrate some subtle interactions between:
- delays experienced by the Finder for noticing changes in the filesystem,
- the fact that AppleScript aliases aren't Finder first-class citizens
- the alias resolution algorithm, never fully disclosed but being said to rely on various pieces of information for tracking the target file (among those pieces, there's indeed the target file's name)
It seems that one may avoid those interactions by changing the contents of folder "testFolder" outside of the Finder, and by providing it with non ambiguously built aliases; for example:
set testFolder to "Mac HD:Users:paul:Desktop:testFolder:"
do shell script "cd " & (quoted form of POSIX path of alias testFolder) & " && rm * && touch file1 && touch file2"
set file1 to alias (testFolder & "file1")
set file2 to alias (testFolder & "file2")
tell application "Finder"
set name of file1 to "tempName"
set name of file2 to "file1"
set name of file1 to "file2"
end tell
The moral could thus be that one should avoid to go beyond the Finder's courtesy wrt aliases: aliases are just a way for the Finder to communicate with the outside world, unaware of Finder references.
Put more briefly: "don't use aliases when not needed".
I understand that your example was built for demonstration purposes, but it could be worth to illustrate above aphorism through a more "natural" twin of your script:
tell application "Finder"
tell folder "Mac HD:Users:paul:Desktop:testFolder:"
delete every file
make new file with properties {name:"file1"} at it
make new file with properties {name:"file2"} at it
set name of file "file1" to "tempName"
set name of file "file2" to "file1"
set name of file "tempName" to "file2"
end tell
end tell
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