------------------------------------------------------------------------------------------- # Auth: Christopher Stone # dCre: 2018/11/30 16:19 # dMod: 2018/11/30 16:52 # Appl: AppleScriptObjC # Task: List a Given Folder as type Furl, type Path, or by Name. # Libs: None # Osax: None # Tags: @Applescript, @Script, @ASObjC, @List, @Folder, @Furl, @Path, @Name ------------------------------------------------------------------------------------------- use AppleScript version "2.4" use framework "Foundation" use scripting additions ------------------------------------------------------------------------------------------- set targetDir to path to downloads folder set itemFurlList to my listFolder:targetDir returningAs:"furl" set itemPathList to my listFolder:targetDir returningAs:"path" set itemNameList to my listFolder:targetDir returningAs:"name" ------------------------------------------------------------------------------------------- --ยป HANDLERS ------------------------------------------------------------------------------------------- on listFolder:targetDir returningAs:returnType -- "furl", "path", "name" set NSDirectoryEnumerationSkipsHiddenFiles to a reference to 4 set NSFileManager to a reference to current application's NSFileManager set {theURLs, theError} to NSFileManager's defaultManager()'s contentsOfDirectoryAtURL:targetDir includingPropertiesForKeys:{} options:(NSDirectoryEnumerationSkipsHiddenFiles) |error|:(reference) if theURLs is equal to missing value then error (theError's localizedDescription() as text) if returnType = "furl" then return theURLs as list else if returnType = "path" then return (theURLs's valueForKey:"path") as list else if returnType = "name" then return (theURLs's valueForKey:"lastPathComponent") as list end if end listFolder:returningAs: -------------------------------------------------------------------------------------------