• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Files of folder returns 0 ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Files of folder returns 0 ...


  • Subject: Re: Files of folder returns 0 ...
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 7 Feb 2002 11:22:46 +0000

Timothy Bates wrote on Thu, 07 Feb 2002 11:41:47 +1100:

>Tried to fix the script by adding brackets to something that shouldn't need
>brackets and, it turns out, doesn't)
>
>tell application "Finder"
> repeat with f in (files of folder "amygdala:Pictures:needfixing:")
> set oldName to name of f as string
> ...
> end
>end
>
>Run it and the result is ...
>
>Script 3fix extensions2 started
>tell application "Finder"
> count every file of folder "amygdala:Pictures:needfixing:"
> --> 0
>end tell
>Script 3fix extensions2 finished
>
>So this is already non-OS9 compatible behaviour.
>
>Then add the "get" coercion and it now works: But this is not needed under
>OS9 AFAIK. And it is ugly. Your brain can no longer read the line as
>"repeat with x in list" it has to do a reflexive parsing of
>"repeat with x in (get a list)"

Maybe that's no bad thing. ;-) It's a common source of errors to confuse
the Finder reference
'every file of folder "blah blah blah" with the list it returns when it's
'got'. If I run this script (which refers to a small folder on my
desktop):

tell application "Finder"
repeat with x in every file of folder "Non-urgent notes" of the
desktop
x
end repeat
end tell

... Script Editor's result window (not the Event Log) shows:

item 4 of every file of folder "Non-urgent notes" of desktop of
application "Finder"

... which is the value of x the last time round the loop. In other words,
x is looping through the Finder reference and item 4 is whatever the
Finder thinks it is at that particular moment. Inserting some variant of
the 'getting' technique:

tell application "Finder"
repeat with x in (get every file of folder "Non-urgent notes" of the
desktop)
x
end repeat
end tell

... the result is:

item 4 of {file "AppSwitcher Preferences" of folder "Non-urgent notes"
of application "Finder", file "Demon details" of folder "Non-urgent
notes" of application "Finder", file "PPG Problems" of folder "Non-urgent
notes" of application "Finder", file "Scripting terms" of folder
"Non-urgent notes" of application "Finder"}

Now x really is looping through a list, as returned before the looping
started.

However, I agree there does seem to be some bug in your particular case.

NG
_______________________________________________
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.

  • Prev by Date: Re: Bitmaps and tiff files
  • Next by Date: date > integer (was UniqueID)
  • Previous by thread: Re: Files of folder returns 0 ...
  • Next by thread: RE: do shell script
  • Index(es):
    • Date
    • Thread