Hi
I have created a macro that adds the tag "edit" to a selection of files in the Finder window.
Now I need a Macro that removes the tag "edit" from all files selected in a Finder window, how can I do that?
tell application "Finder"
activate
set theFolder to (choose folder with prompt "Choose a folder to remove labels from the files within:")
set theFiles to every file of theFolder
repeat with theFile in theFiles
if the label index of theFile is not equal to 0 then
set the label index of theFile to 0
end if
end repeat
open theFolder
end tell
Hey Stig,
I presume you used the Set File Attribute action to “Set Tags to <your-Tag>” – yes?
The same action has the option to remove tags:
You should be able to take your original macro and adjust it to remove instead of add.
-Chris
Hey Oscar,
Stig wanted to work with the selection rather than all files in given folder.
tell application "Finder"
set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
return finderSelectionList
end tell
Finder Labels are not the same as tags, although they have some convergence.
Finder Labels may be set as Label Index 1-9 and cannot be set by name.
Presently you can only set named tags via AppleScript using AppleScriptObjC, although I don't know what changes if any Mojave may bring.
-Chris
You can use the For Each action with the Finders Selection collection to iterate through the selected files, and you can use the Set File Attribute action to add or remove tags.
For Each.kmactions (1.0 KB)
Can this technique (or a similar one) be used to remove all existing tags? If so, how? Thanks
Edit: Quick and dirty solution here.
With the attached macro: Shift F15 removes all existing tags. F15 by itself removes all existing tags, but then adds a green tag.
add green tag.kmmacros (4.6 KB)
Hey Vincent,
All you need to do to change any existing tags or no tags to Green is:
See the Set File Attribute action. ( I have added a little explanation to the “tags.” item.)
-Chris