• 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: List with single values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: List with single values


  • Subject: Re: List with single values
  • From: "Marc K. Myers" <email@hidden>
  • Date: Tue, 24 Jul 2001 14:36:03 -0400
  • Organization: [very little]

> Date: Tue, 24 Jul 2001 08:40:48 -0500
> Subject: List with single values
> From: John Haley <email@hidden>
> To: "email@hidden (E-mail)"
> <email@hidden>
>
> I wish to thank the list for giving me the courage to try and write a real
> applescript for the first time. Before I subscribe to the list I only tried
> to do very simple things.
>
> But now that I am trying to write a real script I have run across a problem
> I know I have seen discussed but I can't seem to find/recall the solution. I
> am having a problem where a variable in a loop is usually a list but can be
> a single item. It crashes the script every time it hits a single value.
> What is the work around for this??
>
> This is what I have been playing with:
>
> tell application "Finder"
> set folderCount to number of folders in (alias loopPathName)
> end tell
> if folderCount > 0 then
> tell application "Finder"
> if folderCount > 1 then
> set foldersList to name of every folder of (alias
> loopPathName)
> display dialog folderList & "list"
> else
> set foldersList to name of folder of (alias loopPathName)
> display dialog folderList & "not list"
> end if
> set folderNameHolder1 to (loopPathName as string)
> end tell
> repeat with folderLoopName in foldersList
> tell application "Finder"
> set folderLoopNameHolder to item itemNum of foldersList
> display dialog folderLoopNameHolder
> set folderNameHolder2 to folderNameHolder1 &
> folderLoopNameHolder & ":"
> moveToNewFolder(folderNameHolder2, pictApend, newFolder,
> newPath) of me
> end tell
> end repeat
> end if
>
> Thanks for any help/suggestions.

The easiest way to deal with it is to coerce your single item into a
list when you first access the contents of the folder:

set foldersList to (name of every folder of (alias loopPathName)) as list

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[7/24/01 2:35:52 PM]


  • Prev by Date: Re: random no. schemes
  • Next by Date: Re: Script Object Order in Script
  • Previous by thread: Are folder actions supposed to work on SFM mounted servers?
  • Next by thread: Dialog Studio Simple Dialog
  • Index(es):
    • Date
    • Thread