20260503

[com.apple.finder]SlicesRootAttributes  AppleSCriptでの設定例

[com.apple.finder]SlicesRootAttributes

NOTE記事一覧ですnote.com

【スクリプトエディタで開く】 |

set_ SlicesRootAttributes.applescript.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+----3----+----4----+----5----+----6----+----7
004(*
005
006FinderWindowの検索の『キー』になる値の設定
007SlicesRootAttributes
008
009
010defaults write がうまくいかない場合はこちらの方法で
011
012
013v1 初回作成
014v1.1 『com_apple_ats_names』はNGみたいなので外した
015
016
017
018com.cocolog-nifty.quicktimer.icefloe *)
019----+----1----+----2----+----3----+----4----+----5----+----6----+----7
020use AppleScript version "2.8"
021use framework "Foundation"
022use framework "AppKit"
023use scripting additions
024property refMe : a reference to current application
025
026####################
027#NSUserDefaultsからDOCKの設定を取り出し
028set appUserDefaults to refMe's NSUserDefaults's standardUserDefaults()
029set ocidDefaultsDict to appUserDefaults's persistentDomainForName:("com.apple.finder")
030set ocidDefaultsDictM to ocidDefaultsDict's mutableCopy()
031#
032set ocidItemArray to ocidDefaultsDictM's objectForKey:("SlicesRootAttributes")
033set ocidItemArrayM to ocidItemArray's mutableCopy()
034############
035set listValue to {"com_apple_ats_name_family", "com_apple_ats_name_fond", "com_apple_ats_name_full", "com_apple_ats_name_postscript", "com_apple_ats_name_style", "com_apple_ats_names", "kMDItemFonts", "kMDItemFonts.ShortName"} as list
036
037set listValue to {"com_apple_ats_name_family", "com_apple_ats_name_fond", "com_apple_ats_name_full", "com_apple_ats_name_postscript", "com_apple_ats_name_style", "kMDItemFonts", "kMDItemFonts.ShortName"} as list
038repeat with itemValue in listValue
039   set boolContain to (ocidItemArrayM's containsObject:(itemValue))
040   if boolContain is false then
041      (ocidItemArrayM's addObject:(itemValue))
042   end if
043end repeat
044############
045set listValue to {"kMDItemKind", "kMDItemLastUsedDate", "kMDItemFSContentChangeDate", "kMDItemContentCreationDate", "kMDItemDisplayName", "kMDItemTextContent"} as list
046repeat with itemValue in listValue
047   set boolContain to (ocidItemArrayM's containsObject:(itemValue))
048   if boolContain is false then
049      (ocidItemArrayM's addObject:(itemValue))
050   end if
051end repeat
052
053############
054set listValue to {"kMDItemXMPCredit", "kMDItemXMPDigitalSourceType"} as list
055repeat with itemValue in listValue
056   set boolContain to (ocidItemArrayM's containsObject:(itemValue))
057   if boolContain is false then
058      (ocidItemArrayM's addObject:(itemValue))
059   end if
060end repeat
061############
062set listValue to {"kMDItemFinderComment", "kMDItemComment", "kMDItemContentModificationDate", "kMDItemMediaTypes", "kMDItemUserTags", "kMDItemEmailAddresses", "com_apple_FileExtensionAttribute", "kMDItemFSInvisible", "kMDItemFSNodeCount", "kMDItemFSCreationDate", "kMDItemFSName", "kMDItemFSSize", "kMDItemFSLabel", "kMDItemColorSpace", "kMDItemLayerNames", "kMDItemPixelCount", "kMDItemPixelWidth", "kMDItemPixelHeight", "kMDItemPageHeight", "kMDItemPageWidth", "kMDItemOrientation", "kMDItemDurationSeconds", "kMDItemBitsPerSample"} as list
063repeat with itemValue in listValue
064   set boolContain to (ocidItemArrayM's containsObject:(itemValue))
065   if boolContain is false then
066      (ocidItemArrayM's addObject:(itemValue))
067   end if
068end repeat
069############
070ocidDefaultsDictM's setObject:(ocidItemArrayM) forKey:("SlicesRootAttributes")
071appUserDefaults's setPersistentDomain:(ocidDefaultsDictM) forName:("com.apple.finder")
072
073set boolDone to appUserDefaults's synchronize()
074
075
076#ここまで
077return
078#ここからはメモ程度
079
080set recordSystemInfo to (system info) as record
081set strUID to (short user name of recordSystemInfo) as text
082set strFilePath to ("/Users/" & strUID & "/Library/Preferences/com.apple.finder.plist") as text
083
084
085repeat with itemValue in listDefValue
086   set strValue to itemValue as text
087   set strCmd to ("/usr/bin/defaults read com.apple.finder SlicesRootAttributes") as text
088   
089   do shell script strCmd
090end repeat
091
092
093
094set strCmd to ("/bin/ps -lax | grep cfprefsd | grep $(id -u)| grep -v grep|awk '{print $2}'") as text
095set strPID to (do shell script strCmd) as text
096
097set strCmd to ("/bin/kill -9 " & strPID & "") as text
098do shell script strCmd
AppleScriptで生成しました