Re: folder of alias "anything" = /Applications
Re: folder of alias "anything" = /Applications
- Subject: Re: folder of alias "anything" = /Applications
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 29 Jul 2004 23:35:34 -0700
On 7/29/04 10:25 PM, "Sander Tekelenburg" <email@hidden> wrote:
>
Suppose you want to do a simple rename of a bunch of JPGs in a folder
>
somewhere, and you make a silly coercion typo like in line 3:
>
>
set theFolder to choose folder
>
tell application "System Events"
>
set theFiles to every file of folder theFolder
>
set fileCount to 1
>
repeat with aFile in theFiles
>
--danger commented out::
>
--set name of aFile to "new filename" & fileCount & ".jpg"
>
set fileCount to fileCount + 1
>
end repeat
>
end tell
>
>
Would you expect it to rename every file in /Applications?
>
>
I sure did not ;) (Luckily I ran this in Script Editor - its Event Log told
>
me what file had been called what, and I could repair. All seems well, thus
>
far.)
>
>
Yes, of course, I shouldn't give myself Admin permissions if I don't know
>
what I'm doing :) What I'm curious about is why this happens. I'd have
>
expected a coercion error being thrown at me. Why does "folder of alias
>
[anything]" point to /Applications?
>
>
>
Note that Script Editor's Event Log says:
>
>
tell application "System Events"
>
get every file of folder (alias "[path to the folder you chose]")
>
>
followed by a listing of every file in /Applications
Since the folder is undefined due to the faulty coercion, it must just go to
the first folder on your startup disk. That's usually /Applications.
Personally, I've never liked how the Finder, and now evidently System
Events, "helps out" poor scripting by coercions like this. It's very sloppy,
and half the time gets something you don't want rather than what you do
want, silently. I, like you, would much prefer that it errored.
--
Paul Berkowitz
_______________________________________________
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.