Tuesday, May 11, 2021

#1 2021-04-01 04:26:08 pm

Fredrik71
Member
Registered: 2019-10-23
Posts: 707

NSURL NSURLResourceKey

I was searching for a easy way to extract allKeys from NSURLResourceKey.

Maybe its useful to someone.

Applescript:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set thePath to POSIX path of (choose file)

set myRecord to my resourceValuesAndKeys:thePath

on resourceValuesAndKeys:thePath
   set NSURLResourceKey to {"NSURLIsApplicationKey", ¬
       "NSURLAddedToDirectoryDateKey", ¬
       "NSURLApplicationIsScriptableKey", ¬
       "NSURLAttributeModificationDateKey", ¬
       "NSURLCanonicalPathKey", ¬
       "NSURLContentAccessDateKey", ¬
       "NSURLContentModificationDateKey", ¬
       "NSURLContentTypeKey", ¬
       "NSURLCreationDateKey", ¬
       "NSURLCustomIconKey", ¬
       "NSURLDocumentIdentifierKey", ¬
       "NSURLEffectiveIconKey", ¬
       "NSURLFileAllocatedSizeKey", ¬
       "NSURLFileContentIdentifierKey", ¬
       "NSURLFileProtectionKey", ¬
       "NSURLFileProtectionType", ¬
       "NSURLFileResourceIdentifierKey", ¬
       "NSURLFileResourceTypeKey", ¬
       "NSURLFileSecurityKey", ¬
       "NSURLFileSizeKey", ¬
       "NSURLGenerationIdentifierKey", ¬
       "NSURLHasHiddenExtensionKey", ¬
       "NSURLIsAliasFileKey", ¬
       "NSURLIsDirectoryKey", ¬
       "NSURLIsExcludedFromBackupKey", ¬
       "NSURLIsExecutableKey", ¬
       "NSURLIsHiddenKey", ¬
       "NSURLIsMountTriggerKey", ¬
       "NSURLIsPackageKey", ¬
       "NSURLIsPurgeableKey", ¬
       "NSURLIsReadableKey", ¬
       "NSURLIsRegularFileKey", ¬
       "NSURLIsSparseKey", ¬
       "NSURLIsSymbolicLinkKey", ¬
       "NSURLIsSystemImmutableKey", ¬
       "NSURLIsUbiquitousItemKey", ¬
       "NSURLIsUserImmutableKey", ¬
       "NSURLIsVolumeKey", ¬
       "NSURLIsWritableKey", ¬
       "NSURLKeysOfUnsetValuesKey", ¬
       "NSURLLabelColorKey", ¬
       "NSURLLabelNumberKey", ¬
       "NSURLLinkCountKey", ¬
       "NSURLLocalizedLabelKey", ¬
       "NSURLLocalizedNameKey", ¬
       "NSURLLocalizedTypeDescriptionKey", ¬
       "NSURLMayHaveExtendedAttributesKey", ¬
       "NSURLMayShareFileContentKey", ¬
       "NSURLNameKey", ¬
       "NSURLParentDirectoryURLKey", ¬
       "NSURLPathKey", ¬
       "NSURLPreferredIOBlockSizeKey", ¬
       "NSURLQuarantinePropertiesKey", ¬
       "NSURLTagNamesKey", ¬
       "NSURLThumbnailDictionaryKey", ¬
       "NSURLTotalFileAllocatedSizeKey", ¬
       "NSURLTotalFileSizeKey", ¬
       "NSURLTypeIdentifierKey", ¬
       "NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey", ¬
       "NSURLUbiquitousItemDownloadRequestedKey", ¬
       "NSURLUbiquitousItemDownloadRequestedKey", ¬
       "NSURLUbiquitousItemDownloadingErrorKey", ¬
       "NSURLUbiquitousItemDownloadingStatusKey", ¬
       "NSURLUbiquitousItemDownloadingStatusKey", ¬
       "NSURLUbiquitousItemDownloadingStatusKey", ¬
       "NSURLUbiquitousItemIsExcludedFromSyncKey", ¬
       "NSURLUbiquitousItemIsUploadingKey", ¬
       "NSURLUbiquitousItemUploadingErrorKey", ¬
       "NSURLUbiquitousItemHasUnresolvedConflictsKey", ¬
       "NSURLUbiquitousItemContainerDisplayNameKey", ¬
       "NSURLUbiquitousSharedItemOwnerNameComponentsKey", ¬
       "NSURLUbiquitousSharedItemCurrentUserPermissionsKey", ¬
       "NSURLUbiquitousSharedItemCurrentUserRoleKey", ¬
       "NSURLUbiquitousItemIsSharedKey", ¬
       "NSURLUbiquitousSharedItemRole", ¬
       "NSURLUbiquitousSharedItemPermissions", ¬
       "NSURLVolumeAvailableCapacityKey", ¬
       "NSURLVolumeAvailableCapacityForImportantUsageKey", ¬
       "NSURLVolumeAvailableCapacityForOpportunisticUsageKey", ¬
       "NSURLVolumeCreationDateKey", ¬
       "NSURLVolumeIdentifierKey", ¬
       "NSURLVolumeIsAutomountedKey", ¬
       "NSURLVolumeIsBrowsableKey", ¬
       "NSURLVolumeIsEjectableKey", ¬
       "NSURLVolumeIsEncryptedKey", ¬
       "NSURLVolumeIsInternalKey", ¬
       "NSURLVolumeIsJournalingKey", ¬
       "NSURLVolumeIsLocalKey", ¬
       "NSURLVolumeIsReadOnlyKey", ¬
       "NSURLVolumeIsRemovableKey", ¬
       "NSURLVolumeIsRootFileSystemKey", ¬
       "NSURLVolumeLocalizedFormatDescriptionKey", ¬
       "NSURLVolumeLocalizedNameKey", ¬
       "NSURLVolumeMaximumFileSizeKey", ¬
       "NSURLVolumeNameKey", ¬
       "NSURLVolumeResourceCountKey", ¬
       "NSURLVolumeSupportsAccessPermissionsKey", ¬
       "NSURLVolumeSupportsAdvisoryFileLockingKey", ¬
       "NSURLVolumeSupportsCasePreservedNamesKey", ¬
       "NSURLVolumeSupportsCaseSensitiveNamesKey", ¬
       "NSURLVolumeSupportsCompressionKey", ¬
       "NSURLVolumeSupportsExclusiveRenamingKey", ¬
       "NSURLVolumeSupportsExtendedSecurityKey", ¬
       "NSURLVolumeSupportsFileCloningKey", ¬
       "NSURLVolumeSupportsFileCloningKey", ¬
       "NSURLVolumeSupportsImmutableFilesKey", ¬
       "NSURLVolumeSupportsJournalingKey", ¬
       "NSURLVolumeSupportsPersistentIDsKey", ¬
       "NSURLVolumeSupportsPersistentIDsKey", ¬
       "NSURLVolumeSupportsFileProtectionKey", ¬
       "NSURLVolumeSupportsRootDirectoryDatesKey", ¬
       "NSURLVolumeSupportsSparseFilesKey", ¬
       "NSURLVolumeSupportsSwapRenamingKey", ¬
       "NSURLVolumeSupportsSymbolicLinksKey", ¬
       "NSURLVolumeSupportsVolumeSizesKey", ¬
       "NSURLVolumeSupportsZeroRunsKey", ¬
       "NSURLVolumeTotalCapacityKey", ¬
       "NSURLVolumeURLForRemountingKey", ¬
       "NSURLVolumeURLKey", ¬
       "NSURLVolumeUUIDStringKey"}
   
   set theURL to current application's |NSURL|'s fileURLWithPath:thePath
   set {theFile, theError} to theURL's resourceValuesForKeys:NSURLResourceKey |error|:(reference)
   return theFile as record
end resourceValuesAndKeys:


if you are the expert, who will you call if its not your imagination.


Filed under: NSURL, NSURLResourceKey

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)