Label

[xattr]フォルダにタグを付与する(sudo対応版)


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# xattrコマンドを使ってタグをセットします
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015#com.apple.LSSharedFileList.ProjectsItems.sfl3を読み込む
016set appFileManager to refMe's NSFileManager's defaultManager()
017set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
018set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
019set ocidSfl3FilePathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems.sfl3") isDirectory:(false)
020# NSDataに読み込んで
021set ocidOption to (refMe's NSDataReadingMappedIfSafe)
022set listResponse to refMe's NSData's dataWithContentsOfURL:(ocidSfl3FilePathURL) options:(ocidOption) |error| :(reference)
023if (item 2 of listResponse) is (missing value) then
024  set ocidReadData to (item 1 of listResponse)
025  log "dataWithContentsOfURL 正常終了"
026else
027  log (item 2 of listResponse)'s code() as text
028  log (item 2 of listResponse)'s localizedDescription() as text
029  return "dataWithContentsOfURL 失敗しました"
030end if
031# unarchivedObjectOfClassで解凍する
032#DATAを解凍する
033set ocidClassListArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:(0))
034(ocidClassListArray's addObject:(refMe's NSDictionary's class))
035(ocidClassListArray's addObject:(refMe's NSMutableDictionary's class))
036(ocidClassListArray's addObject:(refMe's NSArray's class))
037(ocidClassListArray's addObject:(refMe's NSMutableArray's class))
038(ocidClassListArray's addObject:(refMe's NSObject's classForKeyedUnarchiver))
039(ocidClassListArray's addObject:(refMe's NSObject's class))
040#クラスセット
041set ocidSetClass to refMe's NSSet's alloc()'s initWithArray:(ocidClassListArray)
042#解凍
043set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClasses:(ocidSetClass) fromData:(ocidReadData) |error| :(reference)
044if (item 2 of listResponse) = (missing value) then
045  log "unarchivedObjectOfClasses 正常処理"
046  set ocidReadDict to (item 1 of listResponse)
047else if (item 2 of listResponse) ≠ (missing value) then
048  log (item 2 of listResponse)'s code() as text
049  log (item 2 of listResponse)'s localizedDescription() as text
050  return "unarchivedObjectOfClasses エラーしました"
051end if
052#######
053#ダイアログに渡すArray
054set ocidItemNameArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
055#######
056#現在登録済みのタグ名を取得する
057set ocidItemsArray to ocidReadDict's objectForKey:("items")
058repeat with itemDict in ocidItemsArray
059  set ocidName to (itemDict's valueForKey:("Name"))
060  (ocidItemNameArray's addObject:(ocidName))
061end repeat
062set listItemsArray to ocidItemNameArray as list
063try
064  ##############################
065  ###ダイアログを前面に出す
066  set strName to (name of current application) as text
067  if strName is "osascript" then
068    tell application "Finder" to activate
069  else
070    tell current application to activate
071  end if
072  ###
073  set strTitle to "選んでください" as text
074  set strPrompt to "設定するタグを選んでください" as text
075  set listResponse to (choose from list listItemsArray with title strTitle with prompt strPrompt default items (item 1 of listItemsArray) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
076on error
077  log "エラーしました"
078  return "エラーしました"
079  error "エラーしました" number -200
080end try
081if listResponse = {} then
082  return "何も選択していない"
083else if (item 1 of listResponse) is false then
084  return "キャンセルしました"
085  error "キャンセルしました" number -200
086end if
087#####戻り値でPLISTを作っておく
088#PLISTになるArray
089set ocidLabelArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
090#戻り値の数だけタグを設定する
091repeat with itemResponse in listResponse
092  set ocidSetValue to (refMe's NSString's stringWithString:(itemResponse))
093  (ocidLabelArray's addObject:(ocidSetValue))
094end repeat
095###NSDATAのPLISTに変換 データはXML形式
096set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0)
097#set ocidFormat to (refMe's NSPropertyListBinaryFormat_v1_0)
098set ocidPlistSerial to (refMe's NSPropertyListSerialization)
099set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
100set listResponse to ocidPlistSerial's dataWithPropertyList:(ocidLabelArray) format:(ocidFormat) options:(ocidOption) |error| :(reference)
101if (item 2 of listResponse) = (missing value) then
102  log "正常処理"
103  set ocidPlistData to (item 1 of listResponse)
104else if (item 2 of listResponse) ≠ (missing value) then
105  log (item 2 of listResponse)'s code() as text
106  log (item 2 of listResponse)'s localizedDescription() as text
107  return "エラーしました"
108end if
109###テキストに
110set ocidPlistString to refMe's NSMutableString's alloc()'s initWithData:(ocidPlistData) encoding:(refMe's NSUTF8StringEncoding)
111set strPlistString to ocidPlistString as text
112###
113set strName to (name of current application) as text
114if strName is "osascript" then
115  tell application "Finder" to activate
116else
117  tell current application to activate
118end if
119set aliasDefaultLocation to (path to desktop from user domain) as alias
120set strPromptText to "フォルダをえらんでください"
121set strMesText to "フォルダをえらんでください"
122try
123  set listChoosePath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
124on error
125  log "エラーしました"
126  return "エラーしました"
127end try
128
129repeat with itemChoosePath in listChoosePath
130  set aliasChoosePath to itemChoosePath as alias
131  set strDropPath to (POSIX path of aliasChoosePath) as text
132  
133  set strCommandText to ("/usr/bin/xattr -w 'com.apple.metadata:_kMDItemUserTags' '" & ocidPlistString & "'  \"" & strDropPath & "\"")
134  log strCommandText
135  try
136    do shell script strCommandText
137  on error
138    try
139      set strCommandText to ("/usr/bin/sudo /usr/bin/xattr -w 'com.apple.metadata:_kMDItemUserTags' '" & ocidPlistString & "'  \"" & strDropPath & "\"")
140      log strCommandText
141    end try
142  end try
143end repeat
144
AppleScriptで生成しました

|

フォルダにxattrでタグをセットする


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# xattrコマンドを使ってタグをセットします
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015#com.apple.LSSharedFileList.ProjectsItems.sfl3を読み込む
016set appFileManager to refMe's NSFileManager's defaultManager()
017set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
018set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
019set ocidSfl3FilePathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems.sfl3") isDirectory:(false)
020# NSDataに読み込んで
021set ocidOption to (refMe's NSDataReadingMappedIfSafe)
022set listResponse to refMe's NSData's dataWithContentsOfURL:(ocidSfl3FilePathURL) options:(ocidOption) |error| :(reference)
023if (item 2 of listResponse) is (missing value) then
024  set ocidReadData to (item 1 of listResponse)
025  log "dataWithContentsOfURL 正常終了"
026else
027  log (item 2 of listResponse)'s code() as text
028  log (item 2 of listResponse)'s localizedDescription() as text
029  return "dataWithContentsOfURL 失敗しました"
030end if
031# unarchivedObjectOfClassで解凍する
032#DATAを解凍する
033set ocidClassListArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:(0))
034(ocidClassListArray's addObject:(refMe's NSDictionary's class))
035(ocidClassListArray's addObject:(refMe's NSMutableDictionary's class))
036(ocidClassListArray's addObject:(refMe's NSArray's class))
037(ocidClassListArray's addObject:(refMe's NSMutableArray's class))
038(ocidClassListArray's addObject:(refMe's NSObject's classForKeyedUnarchiver))
039(ocidClassListArray's addObject:(refMe's NSObject's class))
040#クラスセット
041set ocidSetClass to refMe's NSSet's alloc()'s initWithArray:(ocidClassListArray)
042#解凍
043set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClasses:(ocidSetClass) fromData:(ocidReadData) |error| :(reference)
044if (item 2 of listResponse) = (missing value) then
045  log "unarchivedObjectOfClasses 正常処理"
046  set ocidReadDict to (item 1 of listResponse)
047else if (item 2 of listResponse) ≠ (missing value) then
048  log (item 2 of listResponse)'s code() as text
049  log (item 2 of listResponse)'s localizedDescription() as text
050  return "unarchivedObjectOfClasses エラーしました"
051end if
052#######
053#ダイアログに渡すArray
054set ocidItemNameArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
055#######
056#現在登録済みのタグ名を取得する
057set ocidItemsArray to ocidReadDict's objectForKey:("items")
058repeat with itemDict in ocidItemsArray
059  set ocidName to (itemDict's valueForKey:("Name"))
060  (ocidItemNameArray's addObject:(ocidName))
061end repeat
062set listItemsArray to ocidItemNameArray as list
063try
064  ##############################
065  ###ダイアログを前面に出す
066  set strName to (name of current application) as text
067  if strName is "osascript" then
068    tell application "Finder" to activate
069  else
070    tell current application to activate
071  end if
072  ###
073  set strTitle to "選んでください" as text
074  set strPrompt to "設定するタグを選んでください" as text
075  set listResponse to (choose from list listItemsArray with title strTitle with prompt strPrompt default items (item 1 of listItemsArray) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
076on error
077  log "エラーしました"
078  return "エラーしました"
079  error "エラーしました" number -200
080end try
081if listResponse = {} then
082  return "何も選択していない"
083else if (item 1 of listResponse) is false then
084  return "キャンセルしました"
085  error "キャンセルしました" number -200
086end if
087#####戻り値でPLISTを作っておく
088#PLISTになるArray
089set ocidLabelArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
090#戻り値の数だけタグを設定する
091repeat with itemResponse in listResponse
092  set ocidSetValue to (refMe's NSString's stringWithString:(itemResponse))
093  (ocidLabelArray's addObject:(ocidSetValue))
094end repeat
095###NSDATAのPLISTに変換 データはXML形式
096set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0)
097#set ocidFormat to (refMe's NSPropertyListBinaryFormat_v1_0)
098set ocidPlistSerial to (refMe's NSPropertyListSerialization)
099set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
100set listResponse to ocidPlistSerial's dataWithPropertyList:(ocidLabelArray) format:(ocidFormat) options:(ocidOption) |error| :(reference)
101if (item 2 of listResponse) = (missing value) then
102  log "正常処理"
103  set ocidPlistData to (item 1 of listResponse)
104else if (item 2 of listResponse) ≠ (missing value) then
105  log (item 2 of listResponse)'s code() as text
106  log (item 2 of listResponse)'s localizedDescription() as text
107  return "エラーしました"
108end if
109###テキストに
110set ocidPlistString to refMe's NSMutableString's alloc()'s initWithData:(ocidPlistData) encoding:(refMe's NSUTF8StringEncoding)
111set strPlistString to ocidPlistString as text
112###
113set strName to (name of current application) as text
114if strName is "osascript" then
115  tell application "Finder" to activate
116else
117  tell current application to activate
118end if
119set aliasDefaultLocation to (path to desktop from user domain) as alias
120set strPromptText to "フォルダをえらんでください"
121set strMesText to "フォルダをえらんでください"
122try
123  set listChoosePath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
124on error
125  log "エラーしました"
126  return "エラーしました"
127end try
128
129repeat with itemChoosePath in listChoosePath
130  set aliasChoosePath to itemChoosePath as alias
131  set strDropPath to (POSIX path of aliasChoosePath) as text
132  
133  set strCommandText to ("/usr/bin/xattr -w 'com.apple.metadata:_kMDItemUserTags' '" & ocidPlistString & "'  \"" & strDropPath & "\"")
134  log strCommandText
135  try
136    do shell script strCommandText
137  end try
138end repeat
139
AppleScriptで生成しました

|

ファイルにxattrでタグをセットする


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# xattrコマンドを使ってタグをセットします
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015#com.apple.LSSharedFileList.ProjectsItems.sfl3を読み込む
016set appFileManager to refMe's NSFileManager's defaultManager()
017set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
018set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
019set ocidSfl3FilePathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems.sfl3") isDirectory:(false)
020# NSDataに読み込んで
021set ocidOption to (refMe's NSDataReadingMappedIfSafe)
022set listResponse to refMe's NSData's dataWithContentsOfURL:(ocidSfl3FilePathURL) options:(ocidOption) |error| :(reference)
023if (item 2 of listResponse) is (missing value) then
024  set ocidReadData to (item 1 of listResponse)
025  log "dataWithContentsOfURL 正常終了"
026else
027  log (item 2 of listResponse)'s code() as text
028  log (item 2 of listResponse)'s localizedDescription() as text
029  return "dataWithContentsOfURL 失敗しました"
030end if
031# unarchivedObjectOfClassで解凍する
032#DATAを解凍する
033set ocidClassListArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:(0))
034(ocidClassListArray's addObject:(refMe's NSDictionary's class))
035(ocidClassListArray's addObject:(refMe's NSMutableDictionary's class))
036(ocidClassListArray's addObject:(refMe's NSArray's class))
037(ocidClassListArray's addObject:(refMe's NSMutableArray's class))
038(ocidClassListArray's addObject:(refMe's NSObject's classForKeyedUnarchiver))
039(ocidClassListArray's addObject:(refMe's NSObject's class))
040#クラスセット
041set ocidSetClass to refMe's NSSet's alloc()'s initWithArray:(ocidClassListArray)
042#解凍
043set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClasses:(ocidSetClass) fromData:(ocidReadData) |error| :(reference)
044if (item 2 of listResponse) = (missing value) then
045  log "unarchivedObjectOfClasses 正常処理"
046  set ocidReadDict to (item 1 of listResponse)
047else if (item 2 of listResponse) ≠ (missing value) then
048  log (item 2 of listResponse)'s code() as text
049  log (item 2 of listResponse)'s localizedDescription() as text
050  return "unarchivedObjectOfClasses エラーしました"
051end if
052#######
053#ダイアログに渡すArray
054set ocidItemNameArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
055#######
056#現在登録済みのタグ名を取得する
057set ocidItemsArray to ocidReadDict's objectForKey:("items")
058repeat with itemDict in ocidItemsArray
059  set ocidName to (itemDict's valueForKey:("Name"))
060  (ocidItemNameArray's addObject:(ocidName))
061end repeat
062set listItemsArray to ocidItemNameArray as list
063try
064  ##############################
065  ###ダイアログを前面に出す
066  set strName to (name of current application) as text
067  if strName is "osascript" then
068    tell application "Finder" to activate
069  else
070    tell current application to activate
071  end if
072  ###
073  set strTitle to "選んでください" as text
074  set strPrompt to "設定するタグを選んでください" as text
075  set listResponse to (choose from list listItemsArray with title strTitle with prompt strPrompt default items (item 1 of listItemsArray) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
076on error
077  log "エラーしました"
078  return "エラーしました"
079  error "エラーしました" number -200
080end try
081if listResponse = {} then
082  return "何も選択していない"
083else if (item 1 of listResponse) is false then
084  return "キャンセルしました"
085  error "キャンセルしました" number -200
086end if
087#####戻り値でPLISTを作っておく
088#PLISTになるArray
089set ocidLabelArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
090#戻り値の数だけタグを設定する
091repeat with itemResponse in listResponse
092  set ocidSetValue to (refMe's NSString's stringWithString:(itemResponse))
093  (ocidLabelArray's addObject:(ocidSetValue))
094end repeat
095###NSDATAのPLISTに変換 データはXML形式
096set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0)
097#set ocidFormat to (refMe's NSPropertyListBinaryFormat_v1_0)
098set ocidPlistSerial to (refMe's NSPropertyListSerialization)
099set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
100set listResponse to ocidPlistSerial's dataWithPropertyList:(ocidLabelArray) format:(ocidFormat) options:(ocidOption) |error| :(reference)
101if (item 2 of listResponse) = (missing value) then
102  log "正常処理"
103  set ocidPlistData to (item 1 of listResponse)
104else if (item 2 of listResponse) ≠ (missing value) then
105  log (item 2 of listResponse)'s code() as text
106  log (item 2 of listResponse)'s localizedDescription() as text
107  return "エラーしました"
108end if
109###テキストに
110set ocidPlistString to refMe's NSMutableString's alloc()'s initWithData:(ocidPlistData) encoding:(refMe's NSUTF8StringEncoding)
111set strPlistString to ocidPlistString as text
112###
113set strName to (name of current application) as text
114if strName is "osascript" then
115  tell application "Finder" to activate
116else
117  tell current application to activate
118end if
119set aliasDefaultLocation to (path to desktop from user domain) as alias
120set strPromptText to "ファイルをえらんでください"
121set strMesText to "ファイルをえらんでください"
122try
123  set listChoosePath to (choose file strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
124on error
125  log "エラーしました"
126  return "エラーしました"
127end try
128
129repeat with itemChoosePath in listChoosePath
130  set aliasChoosePath to itemChoosePath as alias
131  set strDropPath to (POSIX path of aliasChoosePath) as text
132  
133  set strCommandText to ("/usr/bin/xattr -w 'com.apple.metadata:_kMDItemUserTags' '" & ocidPlistString & "'  \"" & strDropPath & "\"")
134  log strCommandText
135  try
136    do shell script strCommandText
137  end try
138end repeat
139
AppleScriptで生成しました

|

ラベル と タグ(macOS14対応)

Comapplelssharedfilelistprojectsitems001Comapplelssharedfilelistprojectsitems002Comapplelssharedfilelistprojectsitems003Comapplelssharedfilelistprojectsitems004



カテゴリー
ラベル タグ
https://quicktimer.cocolog-nifty.com/icefloe/cat76054827/index.html
NSKeyedArchiver
https://quicktimer.cocolog-nifty.com/icefloe/cat76056161/index.html
NSKeyedUnarchiver
https://quicktimer.cocolog-nifty.com/icefloe/cat76055043/index.html
LSSharedFileList (com.apple.LSSharedFileList.ProjectsItems.sfl3)
https://quicktimer.cocolog-nifty.com/icefloe/cat76055054/index.html


以下旧記事のコピー
202402200625551696x990

【A】ラベル
【B】タグ
【C】Label番号
【D】Spotlight検索ビュー
【E】Finderサイドバー
【F】保存済みの検索条件



【A】ラベル
ラベルは基本的には1ファイル1つ設定される
ラベルが複数設定の場合は、内容的には ラベル+複数指定ラベルタグになる
[Label]FInderラベルの色番号を取得する
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-0329e2.html
[Label]FInderラベルの色番号を設定する
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-ff0c42.html
[Label]FInderラベルの色番号を削除=0をセットする
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-5311a4.html
[bash]FInderラベルの色番号を取得する
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-361e8f.html


【A-1】ラベルなし
【A-2】ラベル単色
【A-3】ラベル複数色


【A-1】ラベルなし
[Label]FInderラベルの色番号を削除=0をセットする
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-5311a4.html

2596759092ea2ef1b9b4a43b59400f0f08b36b44
【A-2】ラベル単色
[Label]FInderラベルの色番号を設定する
https://quicktimer.cocolog-nifty.com/icefloe/2024/01/post-ff0c42.html
259676018e95ff77bc54748809ade0ee7a493efa
【A-3】ラベル複数色
ラベル複数色=ラベル単色+色ラベルタグ×複数=複数色指定のラベルはタグになる
ラベル複数色を設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/11/post-c3386f.html
[xattr]コマンドラインからFinerラベルを設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-3f7802.html
2596760740dfab8339f9c4ccf80728972cdbc56f



【B】タグ

[xattr]コマンドラインからFinerラベルを設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-3f7802.html



【B-1】タグ無し
【B-2】色ラベル無しタグ
【B-3】色ラベル有りタグ
ラベル(色)指定のあるタグを作成する
https://quicktimer.cocolog-nifty.com/icefloe/2024/03/post-7f83e9.html
【B-4】複数色ラベルタグ(ラベルのA-3ラベル複数色と同じ)
【macOS14】com.apple.LSSharedFileList.ProjectsItemsはsfl2からsfl3へ
圧縮 アーカイブは
NSKeyedArchiver
https://quicktimer.cocolog-nifty.com/icefloe/cat76056161/index.html
解凍 アン・アーカイブは
NSKeyedUnarchiver
https://quicktimer.cocolog-nifty.com/icefloe/cat76055043/index.html

参照してください


【B-1】タグ無し
[NSURLTagNamesKey]タグ削除
https://quicktimer.cocolog-nifty.com/icefloe/2023/11/post-4d8962.html
2596759092ea2ef1b9b4a43b59400f0f08b36b44
【B-2】色ラベル無しタグ
ラベル色無しのタグを設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-bb420b.html
25967658956a3651a800c4a158b91a603d329489
【B-3】色ラベル有りタグ

2596766509ba1c62a271c40678356cbddfa74111
【B-4】複数色ラベルタグ(ラベルのA-3ラベル複数色と同じ)
タグのみ設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/11/post-83a80b.html
2596760740dfab8339f9c4ccf80728972cdbc56f
【B-5】ラベルNO無し 色付きタグ指定あり
202403250606571334x986
ラベルNO無し 色付きタグ指定ありの ラベルとタグを削除する
https://quicktimer.cocolog-nifty.com/icefloe/2024/03/post-28dd5f.html



【C】Label番号の違い(FinderラベルとOCで逆順)
2593688877a853ca3d34c4a7f8f354355f11353e


【D】Spotlight検索ビュー
設定SlicesRootAttributes
[com.apple.finder] SlicesRootAttributes
https://quicktimer.cocolog-nifty.com/icefloe/2022/05/post-a415d7.html
[Mobileconfig]SlicesRootAttributes
https://quicktimer.cocolog-nifty.com/icefloe/2022/06/post-e92079.html
[com.apple.finder] SlicesRootAttributes その2
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-bd77fe.html
【D-A】ラベル kMDItemFSLabel
【D-B】タグ kMDItemUserTags


【D-A】ラベル kMDItemFSLabel
Screen_1_20240119150001
【D-B】タグ kMDItemUserTags
261828515a9b26ec9c0b94a218744894c21a5df8


【F】保存済みの検索条件
【F-1】ラベル kMDItemFSLabel
【F-2】タグ kMDItemUserTags


コマンドラインからの付与
[xattr]コマンドラインからFinerラベルを設定する
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-3f7802.html


|

ラベルNO無し 色付きタグ指定ありの ラベルとタグを削除する

202403250606571334x986

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# ラベル も全部削除します
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


##############################
### Wクリックで起動時
on run
  ###ドロップレットWクリック時にはファイル選択ダイアログを出す
  set strName to (name of current application) as text
  if strName is "osascript" then
    tell application "Finder" to activate
  else if strName is (name of me as text) then
    set strName to (name of me) as text
    tell application strName to activate
  else
    tell current application to activate
  end if
  ###デフォルトロケーションはデスクトップ
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
  set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
  set strMes to "選んでください"
  set listDropOpenPath to (choose file strMes default location aliasDesktopDirPath with prompt strMes with multiple selections allowed and showing package contents without invisibles) as list
open listDropOpenPath
end run

##################################
###本処理
##################################
on open listDropOpenPath
  
  ######################################
  ###ProjectsItemsからラベル指定のあるタグを取得
  set strSfl3FileName to ("com.apple.LSSharedFileList.ProjectsItems.sfl3") as text
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLArray to appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask)
  set ocidAppSuppDirPathURL to ocidURLArray's firstObject()
  set ocidSharedFilelistDirPathURL to ocidAppSuppDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist") isDirectory:true
  set ocidSfl3FilePathURL to ocidSharedFilelistDirPathURL's URLByAppendingPathComponent:(strSfl3FileName) isDirectory:false
  # NSDataに読み込んで
  set ocidOption to (refMe's NSDataReadingMappedIfSafe)
  set listReadData to refMe's NSData's dataWithContentsOfURL:(ocidSfl3FilePathURL) options:(ocidOption) |error|:(reference)
  if (item 2 of listReadData) is (missing value) then
    set ocidReadData to (item 1 of listReadData)
log "正常終了"
  else
log (item 2 of listReadData)'s localizedDescription() as text
return "失敗しました"
  end if
  # unarchivedObjectOfClassで解凍する
  set listReadData to refMe's NSKeyedUnarchiver's unarchivedObjectOfClass:((refMe's NSObject)'s class) fromData:(ocidReadData) |error|:(reference)
  if (item 2 of listReadData) is (missing value) then
    set ocidPlistDict to (item 1 of listReadData)
log "正常終了"
  else
log (item 2 of listReadData)'s localizedDescription() as text
return "失敗しました"
  end if
  # itemのkLSSharedTagFileListItemLabelがあるものを収集
  set ocidLabelColorDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  ###items のArrayを取り出して
  set ocidItemsArray to ocidPlistDict's objectForKey:("items")
  repeat with itemDict in ocidItemsArray
    set coidTagName to (itemDict's valueForKey:("Name"))
    set ocidCustomItemPropertiesDict to (itemDict's objectForKey:("CustomItemProperties"))
    set ocidColorNO to (ocidCustomItemPropertiesDict's valueForKey:("kLSSharedTagFileListItemLabel"))
    if ocidColorNO ≠ (missing value) then
(ocidLabelColorDict's setValue:(ocidColorNO) forKey:(coidTagName))
    end if
  end repeat
log ocidLabelColorDict as record
  
  #ファイル ディレクトリの全てのパスの格納用
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  #ドロップの数だけ繰り返し
  repeat with itemDropPath in listDropOpenPath
    ###ドップパス
    set appFileManager to refMe's NSFileManager's defaultManager()
    set strDropPath to (POSIX path of itemDropPath) as text
    set ocidDropPathStr to (refMe's NSString's stringWithString:(strDropPath))
    set ocidDropPath to ocidDropPathStr's stringByStandardizingPath()
    set ocidDropPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDropPath))
    ###ドロップされたのが?
    set listResults to (ocidDropPathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference))
    if (item 2 of listResults) = (refMe's NSNumber's numberWithBool:true) then
      # log "このURLはフォルダです"
      ##取得するプロパティ
      set ocidProperties to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
(ocidProperties's addObject:(refMe's NSURLPathKey))
      # (ocidProperties's addObject:(refMe's NSURLIsRegularFileKey))
      # (ocidProperties's addObject:(refMe's NSURLContentTypeKey))
      ##オプション(隠しファイルは含まない)
      set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
      ##コンテンツの収集
      set ocidEmuDict to (appFileManager's enumeratorAtURL:(ocidDropPathURL) includingPropertiesForKeys:(ocidProperties) options:(ocidOption) errorHandler:(reference))
      set ocidFilePathURLArray to ocidEmuDict's allObjects()
      #フォルダ自身も追加しておく
(ocidFilePathURLArray's addObject:(itemDropPath))
    else
      # log "このURLはファイルです"
(ocidFilePathURLArray's addObject:(itemDropPath))
    end if
  end repeat
  
  ###不要なんだが念のためパスをURL順に並び替え
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
(ocidFilePathURLArray's sortUsingDescriptors:{ocidSortDescriptor})
  
  repeat with itemFilePathURL in ocidFilePathURLArray
    ##########
    ##ラベル削除
    set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLLabelNumberKey) |error|:(reference))
    if (item 1 of listResult) is true then
      set ocidGetLabelNo to (item 2 of listResult)
    else
return "LabelNOの取得に失敗しました"
    end if
    set ocidSetLabelNo to (refMe's NSNumber's numberWithInt:(0))
    if ocidGetLabelNo ≠ ocidSetLabelNo then
      set listDone to (itemFilePathURL's setResourceValue:(ocidSetLabelNo) forKey:(refMe's NSURLLabelNumberKey) |error|:(reference))
      if (item 1 of listDone) = true then
log "ラベルを0に設定しました"
      else
log itemFilePathURL's |path| as text
log "ラベルの削除に失敗しました"
      end if
    else
log "ラベルは0が絶定されていました"
    end if
    
    set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    set ocidTagArray to (item 2 of listResult)
    set numCntTagArray to (count of ocidTagArray) as integer
    repeat with itemIntNo from (numCntTagArray - 1) to 0 by -1
      set ocidItemTagName to (ocidTagArray's objectAtIndex:(itemIntNo))
      set ocidLabelName to (ocidLabelColorDict's valueForKey:(ocidItemTagName))
      if ocidLabelName ≠ (missing value) then
(ocidTagArray's removeObjectAtIndex:(itemIntNo))
      end if
    end repeat
    set listDone to (itemFilePathURL's setResourceValue:(ocidTagArray) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    if (item 1 of listDone) = true then
log "タグを削除しました"
    else
log "タグの削除に失敗しました"
    end if
    
  end repeat
  
end open

|

[NSURLTagNamesKey]Windows非互換文字のファイル名フォルダ名にタグ付(修正)

20240322035922384x192

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# フォルダ内のコンテンツを収集して内包されている項目全部処理する
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
property listDeprecatedChar : {"\\", "/", "?", "<", ">", ":", "*", "|", "\"", "¥", ".."} as list

##############################
### Wクリックで起動時
on run
  ###ドロップレットWクリック時にはファイル選択ダイアログを出す
  set strName to (name of current application) as text
  if strName is "osascript" then
    tell application "Finder" to activate
  else if strName is (name of me as text) then
    set strName to (name of me) as text
    tell application strName to activate
  else
    tell current application to activate
  end if
  ###デフォルトロケーションはデスクトップ
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
  set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
  set strMes to "選んでください"
  set listDropOpenPath to (choose folder strMes default location aliasDesktopDirPath with prompt strMes with multiple selections allowed and showing package contents without invisibles) as list
open listDropOpenPath
end run

##################################
###本処理
##################################
on open listDropOpenPath
  ##################################
  #サイドバー項目をチェック
  set strTagName to ("Windows非互換文字") as text
  set numLabelNo to 7 as integer
  ##
  set appFileManager to refMe's NSFileManager's defaultManager()
  set strFileName to "com.apple.LSSharedFileList.ProjectsItems.sfl3" as text
  set ocidURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidAppSuppDirPathURL to ocidURLArray's firstObject()
  set ocidContainerPathURL to (ocidAppSuppDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist") isDirectory:true)
  set ocidSharedFileListURL to (ocidContainerPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false)
  ###NSDATAに読み込みます
  set ocidPlistData to (refMe's NSData's dataWithContentsOfURL:(ocidSharedFileListURL))
  ### NSKeyedUnarchiver's
  set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClass:((refMe's NSObject)'s class) fromData:(ocidPlistData) |error|:(reference)
  set ocidArchveDict to (item 1 of listResponse)
  ### 可変Dictにセット
  set ocidArchveDictM to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidArchveDictM's setDictionary:ocidArchveDict)
  set ocidItemsArray to (ocidArchveDictM's objectForKey:("items"))
  set numCntArray to (count of ocidItemsArray) as integer
  set boolChkTagName to false as boolean
  repeat with itemIntNo from 0 to (numCntArray - 1) by 1
    set itemsArrayDict to (ocidItemsArray's objectAtIndex:(itemIntNo))
    set strItemName to (itemsArrayDict's objectForKey:("Name")) as text
    if strItemName is strTagName then
      set boolChkTagName to true as boolean
log "すでに設定済みです"
    end if
  end repeat
  if boolChkTagName is false then
    ### 項目追加用のDict
    set ocidAddProkectDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    set ocidCustomPropertiesDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ####CustomItemProperties
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("kLSSharedTagFileListItemPinned")
    ##表示させたい場合はここをocidFalseに
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("com.apple.LSSharedFileList.ItemIsHidden")
    ##ラベルカラー
    set ocidLabelNo to refMe's NSNumber's numberWithInteger:(numLabelNo)
ocidCustomPropertiesDict's setValue:(ocidLabelNo) forKey:("kLSSharedTagFileListItemLabel")
    ##CustomItemPropertiesでDictを追加
ocidAddProkectDict's setObject:(ocidCustomPropertiesDict) forKey:("CustomItemProperties")
    ####Bookmark
    set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple-findertag")
ocidURLComponents's setPath:(strName)
    set ocidTagURL to ocidURLComponents's |URL|()
    set listBookMarkData to (ocidTagURL's bookmarkDataWithOptions:(11) includingResourceValuesForKeys:({missing value}) relativeToURL:(missing value) |error|:(reference))
    set ocidBookMarkData to item 1 of listBookMarkData
ocidAddProkectDict's setObject:(ocidBookMarkData) forKey:("Bookmark")
    ##
    set ocidTagName to refMe's NSString's stringWithString:(strName)
ocidAddProkectDict's setObject:(ocidTagName) forKey:("Name")
    ##
    set ocidUUID to refMe's NSUUID's alloc()'s init()
    set ocidUUIDString to ocidUUID's UUIDString()
ocidAddProkectDict's setValue:(ocidUUIDString) forKey:("uuid")
    ##
    set ocidVisibility to refMe's NSNumber's numberWithInteger:(0)
ocidAddProkectDict's setValue:(ocidVisibility) forKey:("visibility")
    ##itemsのArrayに追加
ocidItemsArrayM's addObject:(ocidAddProkectDict)
    ### RootにItemsを追加
(ocidArchveDictM's setObject:(ocidItemsArrayM) forKey:("items"))
    ###NSKeyedArchiver's
    set listSaveData to refMe's NSKeyedArchiver's archivedDataWithRootObject:(ocidArchveDictM) requiringSecureCoding:(false) |error|:(reference)
    set ocidSaveData to item 1 of listSaveData
    #保存
    set listDone to ocidSaveData's writeToURL:(ocidSharedFileListURL) options:0 |error|:(reference)
    if (item 1 of listDone) is false then
log "保存に失敗しました"
    else
log "設定済しました"
    end if
  end if
  
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  
  repeat with itemDropPath in listDropOpenPath
    ###ドップパス
    set appFileManager to refMe's NSFileManager's defaultManager()
    set strDropPath to (POSIX path of itemDropPath) as text
    set ocidDropPathStr to (refMe's NSString's stringWithString:(strDropPath))
    set ocidDropPath to ocidDropPathStr's stringByStandardizingPath()
    set ocidDropPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDropPath))
    ###ドロップされたのが?
    set listResults to (ocidDropPathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference))
    if (item 2 of listResults) = (refMe's NSNumber's numberWithBool:true) then
log "このURLはフォルダです"
      ##取得するプロパティ
      set ocidProperties to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
(ocidProperties's addObject:(refMe's NSURLPathKey))
(ocidProperties's addObject:(refMe's NSURLIsRegularFileKey))
(ocidProperties's addObject:(refMe's NSURLContentTypeKey))
      ##オプション(隠しファイルは含まない)
      set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
      ##コンテンツの収集
      set ocidEmuDict to (appFileManager's enumeratorAtURL:(ocidDropPathURL) includingPropertiesForKeys:(ocidProperties) options:(ocidOption) errorHandler:(reference))
      set ocidFilePathURLArray to ocidEmuDict's allObjects()
      #フォルダ自身も追加しておく
(ocidFilePathURLArray's addObject:(itemDropPath))
    else
log "このURLはファイルです"
(ocidFilePathURLArray's addObject:(itemDropPath))
    end if
  end repeat
  
  ###不要なんだが念のためパスをURL順に並び替え
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
(ocidFilePathURLArray's sortUsingDescriptors:{ocidSortDescriptor})
  
  set ocidDeprecatedArray to refMe's NSArray's arrayWithArray:(listDeprecatedChar)
  set ocidTagArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:(0))
  set ocidTagName to (refMe's NSString's stringWithString:(strTagName))
(ocidTagArray's addObject:(ocidTagName))
  
  repeat with itemFilePathURL in ocidFilePathURLArray
    set ocidLastPath to itemFilePathURL's lastPathComponent()
    ##文字列の最初と最後のスペース
    set ocidCharLength to ocidLastPath's |length|()
    set ocidLastCharRange to refMe's NSMakeRange((ocidCharLength - 1), 1)
    set ocidFirstChar to (ocidLastPath's substringToIndex:(1)) as text
    set ocidLastChar to (ocidLastPath's substringWithRange:(ocidLastCharRange)) as text
    if ocidFirstChar is " " then
      set listDone to (itemFilePathURL's setResourceValue:(ocidTagArray) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    end if
    if ocidLastChar is " " then
      set listDone to (itemFilePathURL's setResourceValue:(ocidTagArray) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    end if
    ##非推奨文字チェック
    repeat with itemDeprecatedChar in ocidDeprecatedArray
      set ocidRange to (ocidLastPath's rangeOfString:(itemDeprecatedChar))
      set ocidLocation to ocidRange's location()
      if ocidLocation = refNSNotFound then
log "含まれていません"
      else
log "対象文字が含まれています"
        set listDone to (itemFilePathURL's setResourceValue:(ocidTagArray) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
      end if
    end repeat
  end repeat
  
  
end open

|

Windows非互換文字にタグ付け

2回チェックすると2こ同じタグがつくが、そこはご容赦
20240313031102500x266

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# macOS14版
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
property refNotFound : a reference to 9.22337203685477E+18 + 5807
set appFileManager to refMe's NSFileManager's defaultManager()

#####################
# タグの有無のチェックと作成
#####################

set strTagName to ("Windows非互換文字") as text
#### LabelNumber
(*
0:ラベル無し
1:グレー
2:グリーン
3:パープル
4:ブルー
5:イエロー
6:レッド
7:オレンジ
*)
set numLabelNo to 5 as integer
#######タグのチェックと追加
#最初の1回だけで2回目からはコメントアウトしてOK
doMakeTagName(strTagName, numLabelNo)
##

###ファイル選択
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
###ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set listUTI to {"public.item"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles, showing package contents and multiple selections allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try

##############################
###チェック対象文字列
##############################
###警告文字リスト
set listProhibit to {"\\", "¥", "<", ">", "*", "?", "\"", "|", "/", ":"} as list
###警告文字リストArrayに
set ocidListProhibitArray to (refMe's NSArray's alloc()'s initWithArray:(listProhibit))


repeat with itemAliasFilePath in listAliasFilePath
  set aliasFilePath to itemAliasFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  
  ###非互換文字があれば数だけカウントアップする
  set numChkProhibit to 0 as integer
  repeat with itemArray in ocidListProhibitArray
    #パス全体を調べる場合
    # set ocidFindRange to (ocidFilePath's rangeOfString:(itemArray))
    #ファイル名だけ調べる場合
    set ocidFindRange to (ocidFileName's rangeOfString:(itemArray))
    #結果
    if (ocidFindRange's location()) = refNotFound then
      ##カウンターはそのまま
      set numChkProhibit to numChkProhibit as integer
      ##非互換文字がある
    else if (ocidFindRange's |length|()) > 0 then
      ##カウンターを1加算
      set numChkProhibit to numChkProhibit + 1 as integer
    end if
  end repeat
  #######################################
  ## 非互換文字があった場合の処理
  if numChkProhibit > 0 then
    #####################
    #現在設定されている値を取得
    set listResult to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    set ocidTagArray to (item 2 of listResult)
    if ocidTagArray = (missing value) then
log "タグは設定されていません"
      #タグの名前
      set ocidTagArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:(0))
      set ocidTagName to (refMe's NSString's stringWithString:(strTagName))
(ocidTagArray's addObject:(ocidTagName))
    else
      set ocidTagName to (refMe's NSString's stringWithString:(strTagName))
(ocidTagArray's addObject:(ocidTagName))
    end if
    ###タグをセット=タグにラベル色指定があるので色付きタグが付与される
    set listDone to (ocidFilePathURL's setResourceValue:(ocidTagArray) forKey:(refMe's NSURLTagNamesKey) |error|:(reference))
    
  end if
  
end repeat



to doMakeTagName(argTagName, argLabelNo)
  try
    set strAgentPath to "/System/Library/LaunchAgents/com.apple.coreservices.sharedfilelistd.plist"
    set strCommandText to ("/bin/launchctl unload -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
  end try
  try
    set strAgentPath to "/System/Library/LaunchAgents/com.apple.cfprefsd.xpc.agent.plist"
    set strCommandText to ("/bin/launchctl unload -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
  end try
  set strName to argTagName as text
  set numLabelNo to argLabelNo as integer
  #######################################
  ##NSdataに読み込み Keyを解凍する
  #######################################
  set appFileManager to refMe's NSFileManager's defaultManager()
  ###処理するファイル名
  set strFileName to "com.apple.LSSharedFileList.ProjectsItems.sfl3" as text
  ###URLに
  set ocidURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidAppSuppDirPathURL to ocidURLArray's firstObject()
  set ocidContainerPathURL to (ocidAppSuppDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist") isDirectory:true)
  set ocidSharedFileListURL to (ocidContainerPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false)
  ###NSDATAに読み込みます
  set ocidPlistData to (refMe's NSData's dataWithContentsOfURL:(ocidSharedFileListURL))
  ### 解凍してDictに Flozenなので値を変更するために 可変に変えます
  #NSKeyedUnarchiver's  OS13までの方式
  # set ocidArchveDict to (refMe's NSKeyedUnarchiver's unarchiveObjectWithData:(ocidPlistData))
  #NSKeyedUnarchiver's  OS14からの方式
  set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClass:((refMe's NSObject)'s class) fromData:(ocidPlistData) |error|:(reference)
  set ocidArchveDict to (item 1 of listResponse)
  ### 可変Dictにセット
  set ocidArchveDictM to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidArchveDictM's setDictionary:ocidArchveDict)
  #######################################
  ### items の処理
  #######################################
  ### items のArrayを取り出して Flozenなので値を変更するために 可変に変えます
  set ocidItemsArray to (ocidArchveDictM's objectForKey:("items"))
  ### 項目入替用のArray 
  set ocidItemsArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
(ocidItemsArrayM's setArray:ocidItemsArray)
  ##################
  ###itemsの数だけ繰り返し
  repeat with itemsArrayDict in ocidItemsArray
    #
    set strItemName to (itemsArrayDict's objectForKey:("Name")) as text
    if strItemName is strName then
      ###値があった場合
      set boolChkTagName to true as boolean
      exit repeat
    else
      ###なかった場合
      set boolChkTagName to false as boolean
    end if
  end repeat
  
  #######################################
  ### タグがない場合は作る
  #######################################
  if boolChkTagName is false then
    ### 項目追加用のDict
    set ocidAddProkectDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    set ocidCustomPropertiesDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ################################CustomItemProperties
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("kLSSharedTagFileListItemPinned")
    ##表示させたい場合はここをocidFalseに
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("com.apple.LSSharedFileList.ItemIsHidden")
    ##ラベルカラー
    set ocidLabelNo to refMe's NSNumber's numberWithInteger:(numLabelNo)
ocidCustomPropertiesDict's setValue:(ocidLabelNo) forKey:("kLSSharedTagFileListItemLabel")
    ##CustomItemPropertiesでDictを追加
ocidAddProkectDict's setObject:(ocidCustomPropertiesDict) forKey:("CustomItemProperties")
    #######################################
    ### Bookmarkデータ生成
    #######################################
    (*
URL形式で
x-apple-findertag:%エンコードされたタグの名前
の形式になります
*)
    set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple-findertag")
ocidURLComponents's setPath:(strName)
    set ocidTagURL to ocidURLComponents's |URL|()
    set listBookMarkData to (ocidTagURL's bookmarkDataWithOptions:(11) includingResourceValuesForKeys:({missing value}) relativeToURL:(missing value) |error|:(reference))
    set ocidBookMarkData to item 1 of listBookMarkData
ocidAddProkectDict's setObject:(ocidBookMarkData) forKey:("Bookmark")
    ##
    set ocidTagName to refMe's NSString's stringWithString:(strName)
ocidAddProkectDict's setObject:(ocidTagName) forKey:("Name")
    ##
    set ocidUUID to refMe's NSUUID's alloc()'s init()
    set ocidUUIDString to ocidUUID's UUIDString()
ocidAddProkectDict's setValue:(ocidUUIDString) forKey:("uuid")
    ##
    set ocidVisibility to refMe's NSNumber's numberWithInteger:(0)
ocidAddProkectDict's setValue:(ocidVisibility) forKey:("visibility")
    ##itemsのArrayに追加
ocidItemsArrayM's addObject:(ocidAddProkectDict)
    ### RootにItemsを追加
(ocidArchveDictM's setObject:(ocidItemsArrayM) forKey:("items"))
    #######################################
    ### 値が新しくなった解凍済みDictをアーカイブする
    #######################################
    ##NSKeyedArchiverに戻す OS13までの形式
    # set listSaveData to (refMe's NSKeyedArchiver's archivedDataWithRootObject:(ocidArchveDictM) requiringSecureCoding:(true) |error|:(reference))
    ##NSKeyedArchiver OS14からの形式
    set listSaveData to refMe's NSKeyedArchiver's archivedDataWithRootObject:(ocidArchveDictM) requiringSecureCoding:(false) |error|:(reference)
    set ocidSaveData to item 1 of listSaveData
    ###########
    ##保存
    set listDone to ocidSaveData's writeToURL:(ocidSharedFileListURL) options:0 |error|:(reference)
    ###########
    ### リロード
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.coreservices.sharedfilelistd.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.cfprefsd.xpc.agent.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
delay 1
    try
do shell script "/usr/bin/killall cfprefsd"
    end try
    try
do shell script "/usr/bin/killall sharedfilelistd"
    end try
  else
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.coreservices.sharedfilelistd.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.cfprefsd.xpc.agent.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
  end if
  
  
end doMakeTagName


|

ラベル(色)指定のあるタグを作成する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# macOS14版
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

#######################################
##設定項目 
#######################################
##追加するタグの名前
set strTagName to ("名称未設定新規タグ") as text
##ラベル番号=色ね
(*
0:ラベル無し
1:グレー
2:グリーン
3:パープル
4:ブルー
5:イエロー
6:レッド
7:オレンジ
*)
set numLabelNo to 6 as integer


###実行
log doMakeTagName(strTagName, numLabelNo)



#######################################
##ファンクション
#######################################
to doMakeTagName(argTagNameText, argLabeClolorNo)
  
  set strName to argTagNameText as text
  set numLabelNo to argLabeClolorNo as integer
  set appFileManager to refMe's NSFileManager's defaultManager()
  ###処理するファイル名
  set strFileName to "com.apple.LSSharedFileList.ProjectsItems.sfl3" as text
  ###URLに
  set ocidURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidAppSuppDirPathURL to ocidURLArray's firstObject()
  set ocidContainerPathURL to (ocidAppSuppDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist") isDirectory:true)
  set ocidSharedFileListURL to (ocidContainerPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false)
  ###NSDATAに読み込みます
  set ocidPlistData to (refMe's NSData's dataWithContentsOfURL:(ocidSharedFileListURL))
  ### 解凍してDictに Flozenなので値を変更するために 可変に変えます
  #NSKeyedUnarchiver's  OS13までの方式
  # set ocidArchveDict to (refMe's NSKeyedUnarchiver's unarchiveObjectWithData:(ocidPlistData))
  #NSKeyedUnarchiver's  OS14からの方式
  set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClass:((refMe's NSObject)'s class) fromData:(ocidPlistData) |error|:(reference)
  set ocidArchveDict to (item 1 of listResponse)
  ### 可変Dictにセット
  set ocidArchveDictM to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidArchveDictM's setDictionary:ocidArchveDict)
  #######################################
  ### items の処理
  #######################################
  ### items のArrayを取り出して Flozenなので値を変更するために 可変に変えます
  set ocidItemsArray to (ocidArchveDictM's objectForKey:("items"))
  ### 項目入替用のArray 
  set ocidItemsArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
(ocidItemsArrayM's setArray:ocidItemsArray)
  ##################
  ###itemsの数だけ繰り返し
  repeat with itemsArrayDict in ocidItemsArray
    #
    set strItemName to (itemsArrayDict's objectForKey:("Name")) as text
    if strItemName is strName then
      ###値があった場合
      set boolChkTagName to true as boolean
      exit repeat
    else
      ###なかった場合
      set boolChkTagName to false as boolean
    end if
  end repeat
log "タグの有無:" & boolChkTagName
  #######################################
  ### タグがない場合は作る
  #######################################
  if boolChkTagName is false then
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.coreservices.sharedfilelistd.plist"
      set strCommandText to ("/bin/launchctl unload -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.cfprefsd.xpc.agent.plist"
      set strCommandText to ("/bin/launchctl unload -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
    ### 項目追加用のDict
    set ocidAddProkectDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    set ocidCustomPropertiesDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
    ################################CustomItemProperties
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("kLSSharedTagFileListItemPinned")
    ##表示させたい場合はここをocidFalseに
    set ocidTrue to refMe's NSNumber's numberWithBool:(true)
ocidCustomPropertiesDict's setValue:(ocidTrue) forKey:("com.apple.LSSharedFileList.ItemIsHidden")
    ##
    set ocidLabelNo to refMe's NSNumber's numberWithInteger:(numLabelNo)
ocidCustomPropertiesDict's setValue:(ocidLabelNo) forKey:("kLSSharedTagFileListItemLabel")
    ##CustomItemPropertiesでDictを追加
ocidAddProkectDict's setObject:(ocidCustomPropertiesDict) forKey:("CustomItemProperties")
    #######################################
    ### Bookmarkデータ生成
    #######################################
    (*
URL形式で
x-apple-findertag:%エンコードされたタグの名前
の形式になります
*)
    set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple-findertag")
ocidURLComponents's setPath:(strName)
    set ocidTagURL to ocidURLComponents's |URL|()
    set listBookMarkData to (ocidTagURL's bookmarkDataWithOptions:(11) includingResourceValuesForKeys:({missing value}) relativeToURL:(missing value) |error|:(reference))
    set ocidBookMarkData to item 1 of listBookMarkData
ocidAddProkectDict's setObject:(ocidBookMarkData) forKey:("Bookmark")
    ##
    set ocidTagName to refMe's NSString's stringWithString:(strName)
ocidAddProkectDict's setObject:(ocidTagName) forKey:("Name")
    ##
    set ocidUUID to refMe's NSUUID's alloc()'s init()
    set ocidUUIDString to ocidUUID's UUIDString()
ocidAddProkectDict's setValue:(ocidUUIDString) forKey:("uuid")
    ##
    set ocidVisibility to refMe's NSNumber's numberWithInteger:(0)
ocidAddProkectDict's setValue:(ocidVisibility) forKey:("visibility")
    ##itemsのArrayに追加
ocidItemsArrayM's addObject:(ocidAddProkectDict)
    ### RootにItemsを追加
(ocidArchveDictM's setObject:(ocidItemsArrayM) forKey:("items"))
    #######################################
    ### 値が新しくなった解凍済みDictをアーカイブする
    #######################################
    ##NSKeyedArchiverに戻す OS13までの形式
    # set listSaveData to (refMe's NSKeyedArchiver's archivedDataWithRootObject:(ocidArchveDictM) requiringSecureCoding:(true) |error|:(reference))
    ##NSKeyedArchiver OS14からの形式
    set listSaveData to refMe's NSKeyedArchiver's archivedDataWithRootObject:(ocidArchveDictM) requiringSecureCoding:(false) |error|:(reference)
    set ocidSaveData to item 1 of listSaveData
    ###########
    ##保存
    set listDone to ocidSaveData's writeToURL:(ocidSharedFileListURL) options:0 |error|:(reference)
    ###########
    ###リロード
    ###########
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.coreservices.sharedfilelistd.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
    try
      set strAgentPath to "/System/Library/LaunchAgents/com.apple.cfprefsd.xpc.agent.plist"
      set strCommandText to ("/bin/launchctl load -w \"" & strAgentPath & "\"") as text
do shell script strCommandText
    end try
delay 1
    try
do shell script "/usr/bin/killall cfprefsd"
    end try
    try
do shell script "/usr/bin/killall sharedfilelistd"
    end try
    
    
  else
    try
do shell script "/usr/bin/killall cfprefsd"
    end try
    
    try
do shell script "/usr/bin/killall sharedfilelistd"
    end try
  end if
  
  
  
  
end doMakeTagName


|

sfltool


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
## 詳細を出力

STR_DATE=$(date +%Y%m%d)
STR_DIST_FIEPATH="$HOME/Documents/Apple/BackgroundItems/$STR_DATE/"
/bin/mkdir -p "$STR_DIST_FIEPATH"
STR_SAVE_FILE_PATH="$HOME/Documents/Apple/BackgroundItems/$STR_DATE.txt"

/usr/bin/sudo /usr/bin/sfltool dumpbtm > "$STR_SAVE_FILE_PATH"

/usr/bin/sudo /usr/bin/sfltool archive -z  "$STR_DIST_FIEPATH"

exit 0

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
## 詳細を出力


/usr/bin/sudo /usr/bin/sfltool resetlist com.apple.LSSharedFileList.RecentApplications
##リストのリセット 対象ファイルを削除しますので より完全なリセットになります
##ファイルが削除されますので 表示数等の設定数がデフォルト値の10になります
## 最近つかった項目>書類
/usr/bin/sudo /usr/bin/sfltool resetlist com.apple.LSSharedFileList.RecentDocuments
## 最近つかった項目>アプリケーション
/usr/bin/sudo /usr/bin/sfltool resetlist com.apple.LSSharedFileList.RecentApplications
##最近使った項目>サーバー
/usr/bin/sudo /usr/bin/sfltool resetlist com.apple.LSSharedFileList.RecentServers
##サーバーに接続>URL入力部に表示される最近つかった項目
/usr/bin/sudo /usr/bin/sfltool resetlist com.apple.LSSharedFileList.RecentHosts

exit 0


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
##項目のリセット  値をクリアするだけでファイルや設定は残る
## 最近つかった項目>書類
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentDocuments
## 最近つかった項目>アプリケーション
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentApplications

##最近使った項目>サーバー
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentServers
##サーバーに接続>URL入力部に表示される最近つかった項目
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentHosts


exit 0


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
## 一覧出力
/usr/bin/sfltool list

exit 0


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
## 一覧出力
/usr/bin/sfltool list

exit 0
com.apple.LSSharedFileList.RecentServers
com.apple.LSSharedFileList.SharePoints
com.apple.LSSharedFileList.FavoriteItems
com.apple.LSSharedFileList.SavedSearches
com.apple.LSSharedFileList.ManagedShared
com.apple.LSSharedFileList.RecentHosts
com.apple.LSSharedFileList.RecentDocuments
com.apple.LSSharedFileList.SessionLoginItems
com.apple.LSSharedFileList.AutomountedServers
com.apple.LSSharedFileList.SFLLaunchdJobs
com.apple.LSSharedFileList.SFLServiceManagementLoginItems
com.apple.LSSharedFileList.FavoriteServers
com.apple.LSSharedFileList.FavoriteVolumes
com.apple.LSSharedFileList.ApplicationRecentDocuments
com.apple.LSSharedFileList.iCloudItems
com.apple.LSSharedFileList.DockApplications
com.apple.LSSharedFileList.GlobalLoginItems
com.apple.LSSharedFileList.RecentApplications
com.apple.LSSharedFileList.NetworkBrowser
com.apple.LSSharedFileList.ProjectsItems
com.apple.LSSharedFileList.ManagedSessionLoginItems

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
## 詳細を出力
/usr/bin/sudo /usr/bin/sfltool dumpbtm


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
##項目のリセット
## 最近つかった項目>書類
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentDocuments
## 最近つかった項目>サーバー
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentHosts
## 最近つかった項目>アプリケーション
/usr/bin/sudo /usr/bin/sfltool clear com.apple.LSSharedFileList.RecentApplications


|

[LSSharedFileList.ProjectsItems]タグの有無のチェック(macOS14 sfl3対応)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
(*
Finder>>設定>>タグに項目がすでにあるか?をチェック
macOS14以降のsfl3版です
*)
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


###有無を確認するタグの名前
set strName to ("CMYK Image")

#######################################
##NSdataに読み込み Keyを解凍する
#######################################
set appFileManager to refMe's NSFileManager's defaultManager()
###処理するファイル名
set strFileName to "com.apple.LSSharedFileList.ProjectsItems.sfl3" as text
###URLに
set ocidURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidAppSuppDirPathURL to ocidURLArray's firstObject()
set ocidContainerPathURL to (ocidAppSuppDirPathURL's URLByAppendingPathComponent:("com.apple.sharedfilelist") isDirectory:true)
set ocidSharedFileListURL to (ocidContainerPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false)
###NSDATAに読み込みます
set ocidPlistData to (refMe's NSData's dataWithContentsOfURL:(ocidSharedFileListURL))
### 解凍してDictに Flozenなので値を変更するために 可変に変えます
#NSKeyedUnarchiver's  OS13までの方式
# set ocidArchveDict to (refMe's NSKeyedUnarchiver's unarchiveObjectWithData:(ocidPlistData))
#NSKeyedUnarchiver's  OS14からの方式
set listResponse to refMe's NSKeyedUnarchiver's unarchivedObjectOfClass:((refMe's NSObject)'s class) fromData:(ocidPlistData) |error|:(reference)
set ocidArchveDict to (item 1 of listResponse)
### 可変Dictにセット
set ocidArchveDictM to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidArchveDictM's setDictionary:ocidArchveDict)
#######################################
### items の処理
#######################################
### items のArrayを取り出して Flozenなので値を変更するために 可変に変えます
set ocidItemsArray to (ocidArchveDictM's objectForKey:("items"))
##################
###itemsの数だけ繰り返し
repeat with itemsArrayDict in ocidItemsArray
  #
  set strItemName to (itemsArrayDict's objectForKey:("Name")) as text
  if strItemName is strName then
    ###値があった場合
    set boolChkTagName to true as boolean
log "指定の名称のタグがすでにあります"
    exit repeat
  else
    ###なかった場合
    set boolChkTagName to false as boolean
  end if
end repeat


return boolChkTagName

|

より以前の記事一覧

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom