[fig 02-08]フォルダのプロパティの取得
#!/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 framework "AppKit"
use scripting additions
####ログ表示
doLogView()
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
set objFileManager to objMe's NSFileManager's defaultManager()
####ミュージックフォルダ
set ocidUserMusicPath to (objFileManager's URLsForDirectory:(objMe's NSMusicDirectory) inDomains:(objMe's NSUserDomainMask))
log ocidUserMusicPath as list
log ocidUserMusicPath as text
####UNIXパス形式に変換(NSSingleObjectArrayをtringで確定させる)
set ocidFileRelativePath to (ocidUserMusicPath's objectAtIndex:0)'s relativePath
log ocidFileRelativePath as text
log className() of ocidFileRelativePath as text
###NSStringにして
set ocidDirPath to objNSString's stringWithString:ocidFileRelativePath
log ocidDirPath as text
log className() of ocidDirPath as text
###attributesOfItemAtPath
set ocidAttributes to objFileManager's attributesOfItemAtPath:ocidDirPath |error|:(missing value)
log ocidAttributes as list
log className() of ocidDirPath as text
(*
ocidAttributesに
NSFileOwnerAccountID
NSFileSystemFileNumber
NSFileExtensionHidden
NSFileSystemNumber
NSFileSize
NSFileGroupOwnerAccountID
NSFileOwnerAccountName
NSFileCreationDate
NSFilePosixPermissions
NSFileProtectionKey
NSFileType
NSFileGroupOwnerAccountName
NSFileReferenceCount
NSFileModificationDate 等が入っています
*)
#########################ログ表示
to doLogView()
tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat
end doLogView
#########################
| 固定リンク
「NSFileManager」カテゴリの記事
- [com.apple.shortcuts.mac-helper] macOS15.3.1での変更点(NSFileManager temporaryDirectoryの戻り値が変わる場合がある)(2025.02.14)
- ファイルのある親フォルダ名をファイル名にする(2024.09.13)
- [contentsOfDirectoryAtURL]コンテンツURLの収集 第一階層のみ(2024.09.02)
- [Skitch]キャッシュをゴミ箱に入れる(2023.11.11)
- [NSFileManager]ファイルのコピー (Acrobatのスタンプデータのバックアップを作成する)(2023.10.20)
「Guide」カテゴリの記事
- [github]初回アクセスからpushまで (2024.04.19)
- [fig 02-09]フォルダ内のアイテム(2022.08.13)
- [fig 02-08]フォルダのプロパティの取得(2022.08.12)
- [fig 02-04]テキストの結合(追加)(2022.08.12)
- [fig 02-03]フォルダの作成と削除(2022.08.12)
「NSFileAttributes」カテゴリの記事
- [NSURLAttributeModificationDateKey]Finder情報の取得(ファイル)(2024.11.26)
- [Foundation.__NSSwiftData]Finderコメントの取得(com.apple.metadata:kMDItemFinderComment)(2024.11.26)
- [NSFileAttributeKey]アクセス権(属性)を設定する(2023.10.25)
- [NSFileManager]Permission ファイル フォルダのアクセス権の設定(2023.10.22)
- フォルダを作って新規テキストファイル(2023.09.29)