How many files could a Finder find if a Finder could find files?
How many files could a Finder find if a Finder could find files?
- Subject: How many files could a Finder find if a Finder could find files?
- From: Nelson Byrne <email@hidden>
- Date: Wed, 17 Mar 2004 12:21:00 -0800
The answer is two, max, given that they have the same name and path.
Before running this for the first time, go to Terminal and type
rm -f Desktop/aaa ; touch Desktop/aaa
This will create a zero length file on your desktop. Now paste the
following script into Script Editor and run it.
================
property FPath : path to desktop
property FName : "aaa"
tell application "Finder"
update FPath
get (every file of FPath where name of it is FName)
make new file at FPath with properties {name:FName}
get (every file of FPath where name of it is FName)
update FPath
end tell
================
Now you have a pair of files on your desktop, each named aaa and with
their icons overlaying one another. They can be moved around
separately. A second execution bombs off at the "make new file."
The Event Log reveals that on the first execution the "get every file"
at the top shows just the one file. Then Finder makes another one
anyway with the exact same name and path, and the "get every file" at
the bottom then returns a list of two items, each the same.
Running it as an app doesn't make this happen, though.
Another oddity is that Finder does not think aaa "exists" (the first
time through (when it's been made by Terminal) even though "get every
file" shows it. This in fact is how I stumbled onto this, because it
made a script I'm working on go down the wrong rabbit hole. I know,
just don't count on "exists" working, instead "get every file" and
check for a non-zero length of the returned list. Maybe we'd better
check on *positive* length, come to think of it, no? You just never
know.
I'm running 10.3.3
Comments very welcome.
Regards,
Nelson Byrne
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.