Recursively tag files in a folder
I want to select a number of files and tag them say "Purple". However, these files exist in a complex directory structure, and it would be much easier to tag the parent folders and then run an automator routine or applescript to tag the child files. Something like:
tell application "Finder"
set theselection to selection
repeat with anitem in theselection
if kind of anitem is "Folder" then
tell application "Finder" to get items of anitem
repeat with eachfile in anitem
set thisFile to eachfile
set newTag to {"Purple"}
set the tags of eachfile to tags eachfile & newtag
end repeat
end if
end repeat
end tell
end run
Clearly the line" set the tags of eachfile to tags eachfile & newtag" is madeup, but could i set it so that it worked?
Any suggestions gratefully received, or I will be spending a lot of time (and mistakes) in diving down to tag files
Mac mini, macOS 13.5