As you may (or may not) remember El Capitan completely frelled my Desktop Sweeper script.
Pre 10.11 it was fast enough if not lightning fast – post 10.11 it slowed to a very unacceptable crawl.
Initially I filled the gap with the Satimage.osax's glob command which is quite nice (instead of a fairly complex Finder whose clause).
The Satimage.osax has made my AppleScripting life sooo much easier since 2003 – long may it live.
Now I'm using the Desktop Sweeper script as a learning project for ASObjC.
It's set up to return a list of «class furl»’s, but I've included code to return POSIX Paths (commented out in the handler).
Thanks again to Shane – without his help I'd still be completely lost in Yonkers.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2016/05/13 23:06
# dMod: 2016/05/16 07:51
# Appl: AppleScriptObjC
# Task: listFilesByExtension → Handler → Example Sweeper
# Aojc: True
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @List, @Files, @Extension, @File_Extension, @Sweeper
-------------------------------------------------------------------------------------------
use framework "Foundation"
use scripting additions
-------------------------------------------------------------------------------------------
set sourceFolder to POSIX path of (path to desktop folder)
set applescriptFileList to its listFilesByExtension:{"scpt", "scptd", "applescript"} fromDirectory:sourceFolder
set bbeditWorksheetList to its listFilesByExtension:{"worksheet"} fromDirectory:sourceFolder
set clippingFileList to its listFilesByExtension:{"textClipping"} fromDirectory:sourceFolder
set compressedArchiveList to its listFilesByExtension:{"sit", "zip"} fromDirectory:sourceFolder
set diskImageList to its listFilesByExtension:{"dmg"} fromDirectory:sourceFolder
set imageFileList to its listFilesByExtension:{"gif", "jpg", "png"} fromDirectory:sourceFolder
set movieFileList to its listFilesByExtension:{"flv", "mov", "mp4"} fromDirectory:sourceFolder
set pdfFiles to its listFilesByExtension:{"pdf"} fromDirectory:sourceFolder
set rtfFileList to its listFilesByExtension:{"rtf", "rtfd"} fromDirectory:sourceFolder
set textFileList to its listFilesByExtension:{"txt"} fromDirectory:sourceFolder
set webArchiveList to its listFilesByExtension:{"webarchive"} fromDirectory:sourceFolder
set webBookmarkList to its listFilesByExtension:{"webbookmark", "webloc"} fromDirectory:sourceFolder
{applescriptFileList, bbeditWorksheetList, clippingFileList, compressedArchiveList, diskImageList, imageFileList, movieFileList, pdfFiles, rtfFileList, textFileList, webArchiveList, webBookmarkList}
-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on listFilesByExtension:listOfExtensions fromDirectory:sourceFolder
set fileManager to current application's NSFileManager's defaultManager()
set aURL to current application's |NSURL|'s fileURLWithPath:sourceFolder
set directoryContents to fileManager's contentsOfDirectoryAtURL:aURL includingPropertiesForKeys:{} options:0 |error|:(missing value)
set foundItemList to current application's NSPredicate's predicateWithFormat_("pathExtension.lowercaseString IN %@", listOfExtensions)
set foundItemList to directoryContents's filteredArrayUsingPredicate:foundItemList
# Return as a list of «class furl»'s
return foundItemList as list
# Return as a list of POSIX Paths
# set foundItemList to (foundItemList's valueForKey:"path") as list
# return foundItemList
end listFilesByExtension:fromDirectory:
-------------------------------------------------------------------------------------------