• 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: Finder Scripting Qusetion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder Scripting Qusetion


  • Subject: Re: Finder Scripting Qusetion
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 23 Feb 2015 23:22:02 +0100


Le 23/02/2015 à 23:08, S. J. Cunningham <email@hidden> a écrit :

How can I get list_4 to be {file1,file2,file3} in the below example?

(I know I can just use set list_4 to list_3 or copy list_3 to list_4 but that doesn't work if I just want to extract parts of list_3 for example)

tell application "Finder"
set list_1 to {1, 2, 3, 4, 5}
set list_2 to {}
repeat with nn in list_1
set list_2 to list_2 & nn
end repeat
--> list_2 = {1,2,3,4,5}  -- Yes!

set list_3 to files of folder someolder
--> list_3 = {file 1,file 2, file 3}

set list_4 to {}
repeat with nn in list_3
set list_4 to list_4 & {nn}
end repeat

--> list_4 = {item 1 of {file 1,file 2, file 3}, item 2 of {file 1,file 2, file 3}, item 3 of {file 1,file 2, file 3}}   -- NO!

-- This works but it's ugly

set list_4 to {}
repeat with nn from 1 to (count of list_3)
set list_4 to list_4 & {item nn of list_3}
end repeat

--> list_4 = {file 1,file 2, file 3}

end tell


You may try :

set someFolder to ((path to desktop as text) & "a folder:") as alias

set list_1 to {1, 2, 3, 4, 5}
set list_2 to {}
repeat with nn in list_1
set list_2 to list_2 & nn
end repeat
--> list_2 = {1,2,3,4,5}  -- Yes!

tell application "Finder"
set list_3 to files of folder someFolder
--> list_3 = {file 1,file 2, file 3}


set list_4 to {}
repeat with nn in list_3
set list_4 to list_4 & {contents of nn}
end repeat
(*
--> list_4 = {item 1 of {file 1,file 2, file 3}, item 2 of {file 1,file 2, file 3}, item 3 of {file 1,file 2, file 3}}   -- NO!


-- This works but it's ugly


set list_4 to {}
repeat with nn from 1 to (count of list_3)
set list_4 to list_4 & {item nn of list_3}
end repeat


--> list_4 = {file 1,file 2, file 3}
*)
end tell


Yvan KOENIG (VALLAURIS, France) lundi 23 février 2015 23:21:57



 _______________________________________________
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: 
 >Finder Scripting Qusetion (From: "S. J. Cunningham" <email@hidden>)

  • Prev by Date: Finder Scripting Qusetion
  • Next by Date: Re: UTC time with milliseconds
  • Previous by thread: Finder Scripting Qusetion
  • Next by thread: clear set property on each run
  • Index(es):
    • Date
    • Thread