jdberry / tag

A command line tool to manipulate tags on Mac OS X files, and to query for files with those tags.
MIT License
1.43k stars 91 forks source link

Controlling Tag Order #53

Open petersparker opened 4 years ago

petersparker commented 4 years ago

First of all, this is a great utility. Thanks!

I'm trying to tag a bunch of movie files, and would like the "Year" tag to always be the first tag in the group. Other tags are actors, directors, and movie type.

Is there a way to control the order of the tag?

I've tried a few things, but it seems to always be a bit random.

Thanks!

petersparker commented 4 years ago

Adding on to this, is there a way to SORT tags on a file?

When you pull up the tag list, it is always out of order - it would be much easier to have the tags sorted.

jdberry commented 4 years ago

Is there a way to control the order of the tag?

In general, ordering of tags is not guaranteed. There is no inherent order to them. At some point somebody proposed an alteration to maintain the ordering of tags on a file, but I never felt like that was a particularly good idea.

When you pull up the tag list, it is always out of order - it would be much easier to have the tags sorted.

Now I'm confused. What operation are you doing to "pull up" the tag list. The tag utility tries to sort the tags before it displays them to you. Is it not doing that?

petersparker commented 4 years ago

Tag works and sorts fine as Tag.

The issue I’m having is displaying tags in a sorted order in the Finder.

My goal in all this was to be able to sort by name or year (using tags) in the Finder.

I turn on the "Tags” display column in the Finder, and from there, you can sort by the first tag.

I have client tax folders, and I have the clients sorted by name, and then use the tag field to sort by year.

I used "find" and “tag" in a script to tag a list of keywords to the files.

That’s when the ordering problem in the Finder became apparent.

In using the command line tag, I found that no matter what order I applied tags, they don’t go in in a deterministic order. Some go in one way, and others go in another.

That’s what lead to all this digging in deeper.

I was able to use some utility (CRS) to list the xml “Plist” of the xattr, and discovered that the order of the tags in the attached xattr xml “plist” are the order they appear in the finder.

Eventually, I was able to use PathFinder 9 to manually reorder the tags in the plist, but manually reordering over 200 tags was a real pain.

If there is a way to ensure the write order of tags to the xattr, it would allow ordering of tags as the Finder sees them.

Again, Tag is a great utility. Keep up the good work.

Hope this helps explain things.

Pete

PS - Some side comments

I also discovered a utility named "Ammonite” which allows tag selection and refinement, with the caveat that is takes a while to handle large tag groups.

Another utility that is useful is “HoudahSpot”, which allows searching for multiple fields across multiple drives, and is very fast, but doesn’t “Zoom” in.

(Apple) BUG REPORT: When using rsync to a Synology NAS, even if you use the -X flag for copying xattr’s, it still loses the tags. Finder copying to a disk does not, but then you have to copy everything all over again.  

On Jun 17, 2020, at 9:35 AM, James Berry notifications@github.com wrote:

Adding on to this, is there a way to SORT tags on a file?

In general, ordering of tags is not guaranteed. There is no inherent order to them.

When you pull up the tag list, it is always out of order - it would be much easier to have the tags sorted.

Now I'm confused. What operation are you doing to "pull up" the tag list. The tag utility tries to sort the tags before it displays them to you. Is it not doing that?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jdberry/tag/issues/53#issuecomment-645477351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVIO35FAMN5ABLSMRVEAD3RXDWEXANCNFSM4N7JJJ7Q.

[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/jdberry/tag/issues/53#issuecomment-645477351", "url": "https://github.com/jdberry/tag/issues/53#issuecomment-645477351", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

jhein05 commented 4 years ago

Tag works and sorts fine as Tag. The issue I’m having is displaying tags in a sorted order in the Finder.

I am using tags since when you had to use OpenMeta. From what I know, tags are stored without any order. If you see them sorted or not, is the job of the app that displays them to you. Looks like tags does that, but the Finder does not. I am using PathFinder too, and I think its tagging functionality sucks too. You might want to have a look at Leap (https://ironicsoftware.com/leap/). It has it's problems too, but it is the best of the tag-aware Finders and does exactly what you describe.

(Apple) BUG REPORT: When using rsync to a Synology NAS, even if you use the -X flag for copying xattr’s, it still loses the tags. Finder copying to a disk does not, but then you have to copy everything all over again.

I would guess, that that's an Apple bug then. I have used rsync multiple times to move data from an old Synology box to a new one and there never were problems with tags.

I am using tags to manage a big archive of files on a Synology NAS including spotlight and it took me years to get everything to work the way I wanted. In case you need some inspiration: In addition to this project, I am using Leap, Noodlesoft Hazel, and Keyboard Maestro.

Good luck :) Julian

ghost commented 2 years ago

Is there a way to control the order of the tag?

In general, ordering of tags is not guaranteed. There is no inherent order to them. At some point somebody proposed an alteration to maintain the ordering of tags on a file, but I never felt like that was a particularly good idea.

I would like to ask you to reconsider. Color tags in particular, are reliably ordered and displayed when set via the Finder (last set tag color is displayed on the left, with a previously set color displayed to its right and underneath):

Finder screenshot

mdls will list the tags in the order they were set:

folders % mdls -raw -name kMDItemUserTags bluegrey
(
    Blue,
    Grey
)%
folders % mdls -raw -name kMDItemUserTags greyblue
(
    Grey,
    Blue
)%
folders %

Sadly, tag --list (as well as tag --set and tag --add) do not retain/respect tag ordering like the Finder:

folders % tag --list bluegrey
bluegray                        Blue,Grey
folders % tag --list greyblue
grayblue                        Blue,Grey
folders %

Because the Finder does appear to reliably support tag ordering, I've come to rely on it to visually differentiate between files using Finder windows (e.g. leftmost tag is the "primary" subject of the file's contents, middle tag the "secondary" subject, rightmost tag is a "minor" subject of the file's contents, with each color representing a specific subject).

I am currently trying to automatically copy tags from source files to identically-named files elsewhere, and tag would fit the bill perfectly, except for the fact that it does not support ordering of tags.

I realize my use-case is rather uncommon, but I figure I can't be the only one using a similar approach, either.

Thanks for your consideration :-)

porg commented 1 year ago

❤️ In general I very much support tag order preservation for all read and write commands in tag!

👉 And specifically for the --add command I created feature request:

porg commented 1 year ago

Why tag order preservation matters... a lot for certain use cases!

https://github.com/jdberry/tag/assets/737143/e0eeceee-7362-4c24-91f0-f702b67400ab

Video Transcript

I love ordered tags! ❤️

porg commented 1 year ago

Another use case: Ordered Tags in macOS Finder for documenting file processing

Ordered Tags in macOS Finder for documenting file processing 1 explained

Ordered Tags in macOS Finder for documenting file processing 2 failure

porg commented 1 year ago

My workaround for now