Get all subfolders in a target folder

The following is a practical example. It gets the paths of all files with a specified extension in my smallish Home folder (Library folder hidden). It then makes these file paths into Shortcuts app files. The script library I posted earlier in this thread is used.

Get Files with Specified Extension.shortcut (23.3 KB)

The timing result when run by Spotlight with both the Foundation framework and Run AppleScript action in memory was 0.40 second. When run by Shortcut Editor, the timing result was 1.04 second. The timing result when using Folder Contents and Filter Files actions was 2.26 second.

One can construct fileURLs from the UNIX find command:

use scripting additions

set rootFolder to quoted form of POSIX path of (choose folder)
-- the parent folder will end with a slash, so we remove it
set allFolders to paragraphs of (do shell script "/usr/bin/find " & rootFolder & " -type d -exec echo \"file://{}\" \\; | sed 's|/$||g'")