画像関連のSlicesRootAttributesの追加(exifカメラ関連のメタは除く)
【スクリプトエディタで開く】 |
SlicesRootAttributes.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | Finderの検索の選択肢にフォント関連の項目を追加します |
| 006 | クラシックな記述で書いてみた |
| 007 | ドメインは |
| 008 | com.apple.finder |
| 009 | キー |
| 010 | SlicesRootAttributes |
| 011 | 値は画像関連で基本的なもののみ |
| 012 |
|
| 013 | kMDItemPhysicalSize 物理サイズ |
| 014 | kMDItemPixelCount ピクセル数 |
| 015 | kMDItemPixelHeight 高さ(ピクセル) |
| 016 | kMDItemPixelWidth 幅(ピクセル) |
| 017 | kMDItemColorSpace 色空間 |
| 018 | kMDItemHasAlphaChannel アルファチャンネル |
| 019 | kMDItemLayerNames レイヤー |
| 020 | kMDItemLogicalSize 論理サイズ |
| 021 | kMDItemOrientation 写真の方向(横または縦) |
| 022 | kMDItemPageWidth 書類のページの幅(ポイント単位) |
| 023 | kMDItemPageHeight 書類のページの高さ(ポイント単位) |
| 024 | kMDItemProfileName カラープロファイル |
| 025 | kMDItemWhereFroms 入手先 |
| 026 | kMDItemPath ファイルパス名 |
| 027 |
|
| 028 | com.cocolog-nifty.quicktimer.icefloe *) |
| 029 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 030 | use AppleScript version "2.8" |
| 031 | use scripting additions |
| 032 |
|
| 033 | set listAddAttributes to {"kMDItemPhysicalSize", "kMDItemPixelCount", "kMDItemPixelHeight", "kMDItemPixelWidth", "kMDItemColorSpace", "kMDItemHasAlphaChannel", "kMDItemLayerNames", "kMDItemLogicalSize", "kMDItemOrientation", "kMDItemPageWidth", "kMDItemPageHeight", "kMDItemProfileName", "kMDItemWhereFroms", "kMDItemPath"} as list |
| 034 |
|
| 035 | #コマンド実行 |
| 036 | set strCmd to ("/usr/bin/defaults read com.apple.finder SlicesRootAttributes") as text |
| 037 | set strStdOut to (do shell script strCmd) as text |
| 038 | #テキスト整形して |
| 039 | set strStdOut to doReplace(strStdOut, "\"", "") as text |
| 040 | set strStdOut to doReplace(strStdOut, ",", "") as text |
| 041 | set strStdOut to doReplace(strStdOut, space & space, "") as text |
| 042 | #リストに |
| 043 | set strDelim to AppleScript's text item delimiters |
| 044 | set AppleScript's text item delimiters to return |
| 045 | set listOrgArray to every text item of strStdOut |
| 046 | set AppleScript's text item delimiters to strDelim |
| 047 |
|
| 048 | repeat with itemAttributes in listAddAttributes |
| 049 | #含まれていないなら 追加 |
| 050 | if listOrgArray does not contain itemAttributes then |
| 051 | set strCmd to ("/usr/bin/defaults write com.apple.finder SlicesRootAttributes -array-add '" & itemAttributes & "'") as text |
| 052 | try |
| 053 | do shell script strCmd |
| 054 | on error strErrMsg number numErrNo |
| 055 | log "No: " & numErrNo & linefeed & "Error:" & strErrMsg |
| 056 | return false |
| 057 | end try |
| 058 | end if |
| 059 | end repeat |
| 060 |
|
| 061 | return 0 |
| 062 |
|
| 063 | ############################ |
| 064 | #文字の置換 |
| 065 | to doReplace(argOrignalText, argSearchText, argReplaceText) |
| 066 | set strDelim to AppleScript's text item delimiters |
| 067 | set AppleScript's text item delimiters to argSearchText |
| 068 | set listDelim to every text item of argOrignalText |
| 069 | set AppleScript's text item delimiters to argReplaceText |
| 070 | set strReturn to listDelim as text |
| 071 | set AppleScript's text item delimiters to strDelim |
| 072 | return strReturn |
| 073 | end doReplace |
| AppleScriptで生成しました |
|---|