AppleScript. How do I get a list of all files in all subfolders without any conditions?

Hello. How in AppleScript to get a list of all files in all subfolders without any conditions? I understand I need to use find. What the code will look like without any conditions, I need to get absolutely all the files: no matter the extension, no matter the file name. The only thing I would like is not to receive hidden files.

Answered by Surikoff in 756619022

ssmith_c, I used shell command "find". You don't know how to do what I need using shell command "find"? application "Finder" returns the result in a very strange way, for example: folder ... of folder ... of folder ... of folder ... of folder ...

something like this

tell application "Finder"
	get entire contents of alias "Users:username:Documents:somefolder"
end tell

but be warned that if somefolder is large, this will take a very long time. This asks the Finder to do the work on behalf of your script. The Finder doesn't show hidden files, so they don't appear in the entire contents result.

There's a post here which uses System Events to do the same thing, with more code, but much quicker (and you'd have to filter out invisible files yourself) https://www.macscripter.net/t/getting-all-files-list-of-directory-and-of-its-subdirectories/71573/4

Did you search for "AppleScript list files and folders"? It wasn't difficult to find these options. Perhaps you did find them but were not happy with the result in your application? If so, please describe what exactly you did try to do, and how it fell short of your expectations.

Accepted Answer

ssmith_c, I used shell command "find". You don't know how to do what I need using shell command "find"? application "Finder" returns the result in a very strange way, for example: folder ... of folder ... of folder ... of folder ... of folder ...

You asked about AppleScript.

You can use ls in a shell to get a list of the contents of a directory, add the -R flag to recurse through directories.

What are you trying to do?

Quote: You asked about AppleScript

I'm just a user and I haven't figured out the terms yet: I don't understand where AppleScript is, where AppleScript isn't. And what is the name of what you proposed?

I don't understand your question "what is the name of what you proposed?". I proposed that you use the 'ls' command, rather than 'find'.

Once again, what are you trying to do?

AppleScript. How do I get a list of all files in all subfolders without any conditions?
 
 
Q