おはようございます。
何かしらのスクリプトなどを記述して実行すると時短になりそうな気がしますが..
(他にももっといい方法があるかもしれませんが...)
そこで、こんなAppleScriptはいかがでしょう。
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
property targTag : "レッド"
set theseFolders to choose folder with multiple selections allowed
set aList to {}
repeat with i in theseFolders
tell (contents of i)
set aRes to getFilePathListWithResolveAlias(it) of me
repeat with ii in aRes
tell (contents of ii)
if targTag is in (getTagsForPath(it as alias) of me) then
set the end of aList to true
else
set the end of aList to false
end if
end tell
end repeat
if true is in aList then
set bRes to getTagsForPath(it) of me
addTagsForPath(bRes & targTag, it) of me
end if
end tell
end repeat
--指定したフォルダの第一階層にあるアイテムのパスを返す
on getFilePathListWithResolveAlias(aFol)
set aURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of aFol)
# 指定フォルダの直下のファイルを取得
set filePaths to current application's NSFileManager's defaultManager's ¬
contentsOfDirectoryAtURL:aURL ¬
includingPropertiesForKeys:{current application's NSURLNameKey} ¬
options:(current application's NSDirectoryEnumerationSkipsHiddenFiles) ¬
|error|:(missing value)
set fList to filePaths as list
if fList = {} then return {}
return fList
end getFilePathListWithResolveAlias
-- get the tags
on getTagsForPath(anAlias)
set aURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of anAlias)
set {theResult, theTags} to aURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theTags = missing value then return {} -- because when there are none, it returns missing value
return theTags as list
end getTagsForPath
-- set the tags, replacing any existing
on setTagsForPath(tagList, anAlias)
set aURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of anAlias)
aURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
end setTagsForPath
-- add to existing tags
on addTagsForPath(tagList, anAlias)
set aURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of anAlias)
-- get existing tags
set {theResult, theTags} to aURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theTags ≠ missing value then -- add new tags
set tagList to (theTags as list) & tagList
set tagList to (current application's NSOrderedSet's orderedSetWithArray:tagList)'s allObjects() -- delete any duplicates
end if
aURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
end addTagsForPath
スクリプトエディタにペーストして、構文確認からの名前をつけて保存で。
スクリプト実行するとフォルダの選択が求められる(フォルダのみ選択可)ので、処理したいフォルダを選択して実行。
スクリプトによって選択したフォルダを順にループ処理が走ります。そのうちの一つずつに対し、第一階層にあるフォルダ・ファイルのタグを検索し、ターゲットのTagが付与されたもの、そうでないもののFlagを立て、そのタグが含まれているものがあれば、最終的にフォルダに対してTagが追加されます。
こちらで動作確認した限りではそれなりに動いていると思いますが、ひとまずテストフォルダ・ファイルでお試しされます?