TagSpace looks like promising UI, productivity tool and I like it. I’m trying to use it with MacOS native tags. I was trying to write a bash script that can use TagSpace tags stored in the file name and converts it into MacOS native tags and back MacOS native tags in the file used to rename the file. My solution is not perfect based on bash script and 3rd party tool that triggers execution of bash script once the files were modified. I’m struggling with this conversion.
I’m heavily invested in Apple and not planing to move out so the “cross platform” idea from marketing perspective sounds nice but not as much actually needed for me as MacOS native tags integration. Also having tags in file names is not for everybody and looks bulky and not nice when having many tags and can easily reach max length of the file path limit. Also files with “tags” in filename doesn’t look good on iPhone once synchronized over iCloud/OneDrive due to limited screen space especially in horizontal view. If you are concerned with “vendor lock in”, you can do import once when you decided to move out from Apple but until then you’ll make Apple users very happy if MacOS native tags are supported out of the box.
Ideally I would love to have TagSpace natively working with MacOS FS tags (not importing them) but adding and removing MacOS native file tags from TagSpace UI as you go. If I forced to choose between MacOS native tags vs TagSpace the “cross platform way”, I would choose MacOS native solution. But if they can work together, I would gladly use TagSpace as UI for macOS tags for automation/productivity.
and thanks for your suggestion. We use for the implementation of the import of MacOS tags, the mdls command. This command can be used unfortunately only for reading the MacOS tags and not for writing. So from my point there is no easy for the implementation of MacOS tag roundtrip. In general we try to keep TagSpaces, working the same way on all supported platform, but I agree with you that such tag-roundtrip will be very handy. If somebody manages to implement such feature, we are ready to integrate it the app, so PRs on GitHub are welcome.
Simple bash script to read & write Mac OS file tags:
# Get the list of macOS file tags from the file and store it in a variable
tags=$(mdls -name kMDItemUserTags -raw "$file")
#add a list of macOS file tags to a file
xattr -w com.apple.metadata:_kMDItemUserTags "$tags" "$file"
So general idea of the synchronization of macOS file tags with tags stored in file name would be:
if file was created or updated start synchronizing steps below (this might be a tricky part how to not process already processed files)
get tags from file name into first array
get tags from macOS with the mdls command into second array
compare the two arrays
If the arrays have exactly the same tags, do nothing, this prevents the loop from running this script endlessly.
If arrays are different, combine two arrays, remove duplicates, write macOS file tags using xattr -w com.apple.metadata:_kMDItemUserTags command and rename the name of the file by removing the old tags from the filename and adding the new tags.
Finish: both filename tags and macOS tags synchronized for the file.
About step 0, how to identify files that were processed and should not be processed again and those which needs to be processed, I’m using Hazel macOS app noodlesoft.com that can do that and run a custom script by comparing date last modified with the “date last matched” for processing. Also alternatively you can track folder on changes and process any files that were recently changed, and if a file does not get any new macOS or filename tags, and we process it, our script is equipped with loop prevention mechanism.