How to check a file’s spotlight tags (especially on a server)

Many thanks to this post for this info.

I recently tagged some files on my Synology NAS mounted with AFP (Finder Go menu, Connect to Server, afp://SERVER.local/VOLUME) but they were not showing up in the Finder.

I still do not know why the Finder is now showing them (the Finder is so problematic) but I did discover how to determine if the tag had been added to the file.

OS X stores the tags in the file’s metadata and I was not sure if Synology’s ext4 would store them or not. You can use the terminal to print out the file’s tags. This is a bit cumbersome as the file as to go in the middle of the command.

The command is:

xattr -p com.apple.metadata:_kMDItemUserTags YOURFILE|xxd -r -p|plutil -convert xml1 - -o -

In this example, replace YOURFILE with the name of your file. Make sure to use “\ ” for every space (or Terminal will think you are starting a new command). For example, if your server’s volume name is “My Server” and the file you want to check is in a folder named “My Files” and the file is named “filetocheck.txt” then the command would look like this:

xattr -p com.apple.metadata:_kMDItemUserTags /Volumes/My\ Server/My\ Files/filetocheck.txt|xxd -r -p|plutil -convert xml1 - -o -

You will see output similar to this:

<?xml version="1.0" encoding="UTF-8"?>

<plist version="1.0">
<array>
<string>Installer</string>