I'm sure there is a shell command that can do this faster, but here is one way in pure Applescript that gives you full control over the formatting of the information you want to display.
property kFileList : {} tell application "Finder" set source_folder to choose folder with prompt "Please select directory." my createList(source_folder) end tell on createList(item_list) set the the_items to list folder item_list without invisibles set item_list to item_list as string repeat with i from 1 to number of items in the the_items set the_item to item i of the the_items set the_item to (item_list & the_item) as alias set this_info to info for the_item set file_name to name of this_info set end of kFileList to file_name if folder of this_info is true then my createList(the_item) end if end repeat end createList
On the side of the note, there is also a list of files with file names that can do this faster than Applescript.
UPDATE:. As a result of this discussion, the function is here again, but this time using the updated API. Perhaps this could lead to some cleaning, but it works with the directory of my desktop quite conveniently (and for me a deep deep folder):
property kFileList : {} tell application "Finder" set source_folder to choose folder with prompt "Please select directory." my createList(source_folder) end tell return kFileList on createList(mSource_folder) set item_list to "" tell application "System Events" set item_list to get the name of every disk item of mSource_folder end tell set item_count to (get count of items in item_list) repeat with i from 1 to item_count set the_properties to "" set the_item to item i of the item_list set the_item to ((mSource_folder & the_item) as string) as alias tell application "System Events" set file_info to get info for the_item end tell if visible of file_info is true then set file_name to displayed name of file_info set end of kFileList to file_name if folder of file_info is true then my createList(the_item) end if end if end repeat end createList
I must be subscribed to the wrong mailing lists or missing because these API changes were accepted and I never heard of them. I used my first proposed method in dozens of projects, mainly because it was the source code offered by Apple, and the complete absence of errors using this (even at the time of writing) never made it necessary to update anything,
Turnabout is fair play, and my apologies for the evil downvote for mmcgrail, and I replace it with upvote. To be clear, I never thought that the answer given by mmcgrail was wrong. This is a great one-line method, but I stayed away from my comments already made. But, rather, it was his voice and his stated context, with which I was offended. In the end, it's just code, and I think we are all here for the same reason: to find the best way to do what we do. It seems that now I have some updates that I can do.
Greetings
Philip regan
source share