• 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: Help with Find and Do with Multiple Applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with Find and Do with Multiple Applications


  • Subject: Re: Help with Find and Do with Multiple Applications
  • From: Yvan KOENIG via AppleScript-Users <email@hidden>
  • Date: Thu, 12 Sep 2019 10:40:26 +0200

Hello

Which system are you running?

Here, under 10.13.6 your script behaves flawlessly.

I just got an error when I tried to apply it to the Desktop itself but it's
normal because it's not a "Finder Window".
After asking the Finder to create a new window with the Desktop, it worked.

Just for the pleasure, I made some cosmetic changes :


tell application "Finder"
        -- generate a list of file references sorted by size
        set these_items to sort (get every document file ¬
                of the front Finder window) by physical size
        -- generate a list of names
        set these_names to {}
        repeat with anItem in these_items
                set end of these_names to name of anItem
        end repeat
end tell
-- convert the list of names to a paragraph-delimited text block
set oldTID to AppleScript's text item delimiters # save the original delimiters
set AppleScript's text item delimiters to {return} # define the new one
set item_list to these_names as string
set AppleScript's text item delimiters to oldTID # reset the original delimiters

-- make a new document with the text
tell application "TextEdit"
        activate
        make new document
        set text of document 1 to item_list
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 12
septembre 2019  10:39:56





> Le 12 sept. 2019 à 05:56, Kellen Ruyle via AppleScript-Users
> <email@hidden> a écrit :
>
> Hi! I am new to AppleScript and have been going through AppleScript 1-2-3 by
> Sal Soghoian and Bill Cheeseman. It’s great and I am learning a lot.
>
> I am working through a script but it seems to give me an error “Finder got an
> error; AppleEvent handler failed.”number-10000
>
> I am trying to generate a list of the names of the image files displayed in
> the frontmost Finder window, sorted by their file size, and then creating a
> new document in TextEdit containing the list of names. I can attach
> screenshot if need be. I have copied and pasted the code below. Any help
> would be great thanks!
>
> tell application "Finder"
>    -- generate a list of file references sorted by size
>    set these_items to sort (get every document file ¬
>          of the front Finder window) by physical size
>    -- generate a list of names
>    set these_names to {}
>    repeat with i from 1 to the count of these_items
>            set the end of these_names to ¬
>                  the name of (item i of these_items)
>    end repeat
> end tell
> -- convert the list of names to a paragraph-delimited text block
> set AppleScript's text item delimiters to return
> set the item_list to these_names as string
> set AppleScript's text item delimiters to {""}
> -- make a new document with the text
> tell application "TextEdit"
>    activate
>    make new document
>    set text of document 1 to the item_list
> end tell
>
> I greatly appreciate it!
>
> Regards,
> Kel

 _______________________________________________
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: 
 >Help with Find and Do with Multiple Applications (From: Kellen Ruyle via AppleScript-Users <email@hidden>)

  • Prev by Date: Help with Find and Do with Multiple Applications
  • Next by Date: Re: Help with Find and Do with Multiple Applications
  • Previous by thread: Help with Find and Do with Multiple Applications
  • Next by thread: Re: Help with Find and Do with Multiple Applications
  • Index(es):
    • Date
    • Thread