• 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: whose class is folder...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: whose class is folder...


  • Subject: Re: whose class is folder...
  • From: Brian Christmas <email@hidden>
  • Date: Sat, 07 Apr 2018 09:19:48 +1000

From my testing,  believe there’s a basic problem or problems that wiser minds
than mine might address.

In your failing example, the class returned is actually ‘cfol’, but that’s
treated as a variable.

However, if you coerce the line to return text, it returns ‘folder’

But there’s the rub, coercing class to text in a one liner simply wraps the
term ‘class’ in quotes, instead of it’s value in quotes.

Here’s a multi line example that works, PROVIDED the folder is not open.
Following it is my one-liner attempts.

Santa

tell application "Finder"
        activate
        selection as list
        -->{folder "ScreenShots" of folder "Desktop" of folder "OzSanta" of
folder "Users" of startup disk of application "Finder"}
        set theSelection to (selection as list)
        set theChoice to ""
        repeat with eachItem in theSelection
                #tell application "System Events" to display dialog (class of
eachItem) --> cfol
                #tell application "System Events" to display dialog (class of
eachItem) as text --> "folder"
                if (class of eachItem) as text is "folder" then
                        say 1
                        set theChoice to eachItem
                        exit repeat
                end if
        end repeat
        try
                #open theChoice
        end try
end tell

tell application "Finder"
        try
                say 2
                try
                        set theChoice to item 1 of ((selection as list) where
(class is cfol)) as list
                end try
                say 3
                set theChoice to item 1 of ((selection as list) where (class as
text is "folder")) as list
                --> Can’t get {folder "ScreenShots" of folder "Desktop" of
folder "OzSanta" of folder "Users" of startup disk of application "Finder"}
whose "class" = "folder". Access not allowed.
                open theChoice
        on error errmsg
                tell application "System Events" to display dialog errmsg
        end try
end tell





> On 7 Apr 2018, at 7:49 am, Jean-Christophe Helary
> <email@hidden> wrote:
>
> I'm having issues understanding basic filtering it seems:
>
> tell application "Finder"
>       class of item 1 of (selection as list)
> end tell
>
> this returns folder
> (if I select a folder, that is)
>
> but if I do
>
> tell application "Finder"
>       item of (selection as list) whose class is folder
> end tell
>
> I get a "can't get item of {...}" -1,728 error...
>
>
> Jean-Christophe Helary
> -----------------------------------------------
> http://mac4translators.blogspot.com <http://mac4translators.blogspot.com/>
> @brandelune
>
>
> _______________________________________________
> 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

 _______________________________________________
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

References: 
 >whose class is folder... (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: Finder's "insertion location"
  • Next by Date: Re: whose class is folder...
  • Previous by thread: whose class is folder...
  • Next by thread: Re: whose class is folder...
  • Index(es):
    • Date
    • Thread