Previous | Index | Next |
URL and File related methods
resourceValuesForKeys:forFilesIn:recursive:skipHidden:skipInsidePackages:
As resourceValuesForKeys:forItemsIn:recursive:skipHidden:skipInsidePackages:, but only return values for files and packages, not folders. Always includes the values for NSURLPathKey and NSURLIsPackageKey.
+ (NSArray *)resourceValuesForKeys:(NSArray *)resourceKeys forFilesIn:(NSArray *)urlFolderOrPath recursive:(BOOL)recurseFlag skipHidden:(BOOL)hiddenFlag skipInsidePackages:(BOOL)skipInPackagesFlag
resourceKeys = array or list of resource keys
urlFileOrPath = alias, file, HFS path, POSIX path or NSURL
recurseFlag = whether to recurse through any folders
hiddenFlag = whether to ignore hidden items
skipInPackagesFlag = whether to include files within file packages
Array of dictionaries/records of resource key values
Version 1.3.0
use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework
set urlFileOrPath to "~/Desktop"
set resourceKeys to {current application's NSURLAddedToDirectoryDateKey, current application's NSURLCreationDateKey}
set theResult to current application's SMSForder's resourceValuesForKeys:resourceKeys forFilesIn:urlFileOrPath recursive:true skipHidden:true skipInsidePackages:true
ASify from theResult
--> {{NSURLCreationDateKey:date "Tuesday, 9 June 2015 at 10:53:10 AM", _NSURLPathKey:"/Users/shane/Desktop/10.11 Changes.webarchive", NSURLAddedToDirectoryDateKey:date "Friday, 25 September 2015 at 5:39:05 PM"}, [...]}
theResult as list -- 10.11 only
--> {{NSURLCreationDateKey:date "Tuesday, 9 June 2015 at 10:53:10 AM", _NSURLPathKey:"/Users/shane/Desktop/10.11 Changes.webarchive", NSURLAddedToDirectoryDateKey:date "Friday, 25 September 2015 at 5:39:05 PM"}, [...]}
theResult as list -- 10.9 and 10.10
--> {{NSURLCreationDateKey:(NSDate) 2015-06-09 00:53:10 +0000, _NSURLPathKey:"/Users/shane/Desktop/10.11 Changes.webarchive", NSURLAddedToDirectoryDateKey:(NSDate) 2015-09-25 07:39:05 +0000}, [...]}
set sortDesc to current application's NSSortDescriptor's sortDescriptorWithKey:(current application's NSURLCreationDateKey) ascending:true
set sortedValues to theResult's sortedArrayUsingDescriptors:{sortDesc}
set thePaths to sortedValues's valueForKey:(current application's NSURLPathKey)
ASify from thePaths
--> <recursive list of POSIX paths of files and packages sorted by creation date>
thePaths as list
--> <recursive list of POSIX paths of files and packages sorted by creation date>