• 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: simple “repeat with” problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple “repeat with” problem


  • Subject: Re: simple “repeat with” problem
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 09 Dec 2016 15:53:23 -0600

On Dec 09, 2016, at 15:31, Mitchell L Model <email@hidden> wrote:
Despite my long years of AppleScripting I despair of ever understanding the subtleties of "repeat with" loops … This does not work:


Hey Mitchell,

This is one of those cases where an explicit “get” is needed:

-------------------------------------------------
set theFolder to path to fonts folder from local domain
set theFonts to {}

tell application "Finder"
   repeat with theFile in (get the files of the theFolder)
      set end of theFonts to name of theFile
   end repeat
end tell

theFonts

-------------------------------------------------

Generally I prefer NOT to do it this way, because the file-list isn't an object available to inspect in Script Debugger – and that can make debugging more difficult.

However – that won't stop me from using the form in something quick and dirty that I know will work.

The following method is much faster:

-------------------------------------------------

set theFolder to path to fonts folder from local domain

tell application "Finder"
   set fontNameList to name of files of theFolder
end tell

fontNameList

-------------------------------------------------

--
Take Care,
Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: simple “repeat with” problem
      • From: Mitchell L Model <email@hidden>
References: 
 >simple “repeat with” problem (From: Mitchell L Model <email@hidden>)

  • Prev by Date: Re: trivial Finder path problem
  • Next by Date: Re: trivial Finder path problem
  • Previous by thread: simple “repeat with” problem
  • Next by thread: Re: simple “repeat with” problem
  • Index(es):
    • Date
    • Thread