« [changeCurrentDirectoryPath]作業用ディレクトリの移動 | トップページ | [Contacts]選択中のアドレスのQRコードを作成します »

[attributesOfItemAtPath]属性の取得

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
set objFileManager to objMe's NSFileManager's defaultManager()


set aliasFilePath to (choose file with prompt "ファイルを選んでください" default location (path to desktop folder from user domain) of type {"public.item"} with invisibles and showing package contents without multiple selections allowed) as alias
###選択したファイルのパス
set strFilePath to POSIX path of aliasFilePath
###NSStringにして
set ocidDirPath to objNSString's stringWithString:strFilePath
###attributesOfItemAtPath
set ocidAttributes to objFileManager's attributesOfItemAtPath:ocidDirPath |error|:(missing value)
###
# ここでocidAttributesにファイルのattributes属性がocidで入ります
###
log ocidAttributes
log ocidAttributes's className() as text
-->(* NSFileAttributes*)
log ocidAttributes as list

###################
##NSFileOwnerAccountID
set ocidNSFileOwnerAccountID to ocidAttributes's NSFileOwnerAccountID
log ocidNSFileOwnerAccountID
log ocidNSFileOwnerAccountID's className() as text
-->(*__NSCFNumber*)
log ocidNSFileOwnerAccountID as text
-->ファイルの所有者のUID
###################
##NSFileOwnerAccountName
set ocidNSFileOwnerAccountName to ocidAttributes's NSFileOwnerAccountName
log ocidNSFileOwnerAccountName
log ocidNSFileOwnerAccountName's className() as text
-->(*__NSCFString*)
log ocidNSFileOwnerAccountName as text
-->ファイルの所有者のアカウント名
###################
##NSFileGroupOwnerAccountID
set NSFileGroupOwnerAccountID to ocidAttributes's NSFileGroupOwnerAccountID
log NSFileGroupOwnerAccountID
log NSFileGroupOwnerAccountID's className() as text
-->(*__NSCFNumber*)
log NSFileGroupOwnerAccountID as text
-->ファイルの所有者のグループGID
###################
##NSFileGroupOwnerAccountName
set NSFileGroupOwnerAccountName to ocidAttributes's NSFileGroupOwnerAccountName
log NSFileGroupOwnerAccountName
log NSFileGroupOwnerAccountName's className() as text
-->(*__NSCFString*)
log NSFileGroupOwnerAccountName as text
-->ファイルの所有者のグループ名staff

###################
##NSFileCreationDate
set ocidNSFileCreationDate to ocidAttributes's NSFileCreationDate
log ocidNSFileCreationDate
log ocidNSFileCreationDate's className() as text
-->(* __NSTaggedDate*)
log ocidNSFileCreationDate as date
-->(*date 2022422 金曜日 0:48:11*)

###################
##NSFileModificationDate
set ocidNSFileModificationDate to ocidAttributes's NSFileModificationDate
log ocidNSFileModificationDate
log ocidNSFileModificationDate's className() as text
-->(* __NSTaggedDate*)
log ocidNSFileModificationDate as date
-->(*date 2022422 金曜日 0:48:11*)

###################
##NSFileSize ファイルサイズ
set ocidNSFileSize to ocidAttributes's NSFileSize
log ocidNSFileSize
log ocidNSFileSize's className() as text
-->(*__NSCFNumber*)
log ocidNSFileSize as integer
-->(*9999999*)

###################
##NSFilePosixPermissions
set ocidNSFilePosixPermissions to ocidAttributes's NSFilePosixPermissions
log ocidNSFilePosixPermissions
log ocidNSFilePosixPermissions's className() as text
-->(*__NSCFNumber*)
log ocidNSFilePosixPermissions as integer
-->(* 420*)=オーナーが6って事でしょうか?
-->4=読み込みOK
-->2=書き込みOK
-->0=実行NG



###################
##NSFileExtendedAttributes
set ocidNSFileExtendedAttributes to ocidAttributes's NSFileExtendedAttributes
log ocidNSFileExtendedAttributes
log ocidNSFileExtendedAttributes's className() as text
-->(*__NSCFNumber*)
log ocidNSFileExtendedAttributes as list
###NSFileExtendedAttributesocidNSFileExtendedAttributesに格納して
########
##com.apple.TextEncoding
set ocidNSFileExtendedAttributesTextEncoding to ocidNSFileExtendedAttributes's |com.apple.TextEncoding|
###
log ocidNSFileExtendedAttributesTextEncoding
log ocidNSFileExtendedAttributesTextEncoding's className() as text
(*NSConcreteData*)
log ocidNSFileExtendedAttributesTextEncoding
####NSConcreteDataをテキストに
set ocidString to objNSString's alloc()'s initWithData:ocidNSFileExtendedAttributesTextEncoding encoding:(objMe's NSUTF8StringEncoding)
log ocidString as text

|

« [changeCurrentDirectoryPath]作業用ディレクトリの移動 | トップページ | [Contacts]選択中のアドレスのQRコードを作成します »

AppleScript NSFileManager」カテゴリの記事

AppleScript NSFileAttributes」カテゴリの記事