Using tags to organise files long-term

Discussion in 'macOS' started by thiskiwicanfly, Oct 7, 2018.

Tags:
  1. thiskiwicanfly, Oct 7, 2018
    Last edited: Oct 7, 2018

    thiskiwicanfly macrumors newbie

    Joined:
    Oct 14, 2015
    Location:
    NZ
    #1
    Hi everyone,

    I've recently decided to start using tags to better organise the files on my Mac - as I'm convinced it's a much better method to categorise files, rather than using text stored in the file's comment field (which I've been doing up until now).

    However, before I start using my new custom tags in favour of using text in the comments field, I'm curious to know...

    Where is the tag information kept? More to the point, if I ever copy a custom-tagged file to a new Mac - or if I ever need to recover my Mac from a fresh install and copy the tagged files back - will my new custom tags be lost?

    I intend to tag a large number of files, so I don't want to find myself back at square one in a worst-case scenario.
     
  2. Brian33 macrumors 6502a

    Joined:
    Apr 30, 2008
    Location:
    USA (Virginia)
    #2
    It appears that the tag information is kept as "extended attributes" of the file. I was curious so I used to some Terminal commands (see below) to display the extended attributes of a file to which I had assigned two tags via Finder. I assigned one of the default color tags (Purple) and one that I made up ("a-new-tag"). My test file was called "foo".

    The -@ option of the 'ls' command will display the names of all the extended attributes of a file:

    brian@macbook:~(0)$ ls -l@ foo
    -rw-r--r--@ 1 brian staff 31 Oct 9 12:56 foo
    com.apple.FinderInfo 32
    com.apple.metadata:_kMDItemUserTags 65


    From that it appears the tag info is stored in the "kMDItemUserTags" attribute. (You can ignore the FinderInfo attribute.)

    The 'xattr' command can display the attribute names and values:

    brian@macbook:~(0)$ xattr -l foo
    com.apple.FinderInfo:
    00000000 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 |................|
    00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    00000020
    com.apple.metadata:_kMDItemUserTags:
    00000000 62 70 6C 69 73 74 30 30 A2 01 02 58 50 75 72 70 |bplist00...XPurp|
    00000010 6C 65 0A 33 59 61 2D 6E 65 77 2D 74 61 67 08 0B |le.3Ya-new-tag..|
    00000020 14 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 |................|
    00000030 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    00000040 1E |.|
    00000041


    Notice that the UserTags attribute contains the strings "Purple" and "a-new-tag".

    I expect that the tag info will be preserved for a file, even if it is moved or copied, as long as the method used is aware of extended attributes. Finder should certainly be fine. A quick test showed that the 'cp' (copy) command also preserved the tags. Any MacOS-aware program SHOULD preserve extended attributes, but there may be some that don't. Maybe someone with more experience will chime in here...
     
  3. thiskiwicanfly thread starter macrumors newbie

    Joined:
    Oct 14, 2015
    Location:
    NZ
    #3
    Thanks Brian33! Yes, I can see it certainly keeps the tag information intact as long as the file is retained in the macOS file system.

    I also did a quick test by creating a text file on an external drive formatted in HFS+, then created a new custom tag on that file. I unmounted the external drive, and then removed the new tag from the tag list in Finder (Preferences -> Tags). When I reconnected the drive, the new custom tag was automatically re-created. So it works!

    Interestingly enough, when I unmounted the external drive again, the new tag was automatically removed from the tag list. So it seems macOS knows that if I choose to remove a custom tag after the source drive has been removed, then it turns that new tag into "a dynamic tag" (it only exists while the source drive is connected), otherwise all new tag stays present on macOS all the time, even if the external drive has been disconnected. Amazing!
     
  4. JanErik75 macrumors newbie

    JanErik75

    Joined:
    Aug 3, 2014
    Location:
    Norway
    #4
    This is indeed great news.

    However, if you use a cloud backup service, you need to make sure that custom tags are not stripped when files and folders are uploaded to their servers. You don't want to find out that your meticulously crafted tags are missing when restoring from a cloud backup. Backblaze is a major culprit in this regard. There might be others too.

    So when choosing a cloud backup provider, make sure you choose one that keeps all your metadata intact.
     
  5. thiskiwicanfly thread starter macrumors newbie

    Joined:
    Oct 14, 2015
    Location:
    NZ
    #5
    That's a great point! I didn't think of that. Fortunately, in this case, most of my custom tags are for local files that I never intend on backing up to a cloud service, but gets backed up on a secondary USB (HFS+ formatted) drive instead.

    But I'm really surprised and curious why cloud backup providers such as Backblaze would strip tags from uploaded files. Considering metadata file size storage is rather minimal, I couldn't imagine it's done to manage capacity on their servers. But I could be wrong.

    Which makes me wonder what would happen if I ever decide to host the tagged files on a NAS (Synology) instead? I believe the majority of NAS devices use the BTRFS file system - so I would assume it would store file metadata?
     
  6. thiskiwicanfly, Oct 15, 2018
    Last edited: Oct 16, 2018

    thiskiwicanfly thread starter macrumors newbie

    Joined:
    Oct 14, 2015
    Location:
    NZ
    #6
    I've done a bit more research into "extended metadata" on the macOS and I've read that EXIF metadata that is associated with photo/image files is saved to the file itself, so is easily transferrable across OS platforms. Extended metadata for video files (also know as Descriptive Metadata) that stores information such as "cast", "producer", "director", "genre" etc, is also saved to the file itself, so should also be transferrable across services and other systems - as long as the service doesn't intentionally strip the extended metadata out in the copy process, such as some cloud storage backup services.
     

Share This Page

5 October 7, 2018