tag icon indicating copy to clipboard operation
tag copied to clipboard

Possibility to rename tags themselves

Open porg opened this issue 3 years ago • 1 comments

User Goal

  • As a user I sometimes need to set or move a bunch of tags into their own or a new namespace by adding a prefix into their name and would love to do that in an efficient manner.
  • Currently this is tedious manual work in Finder: Sidebar > Tags > All Tags > Right click a certain tag > Rename > Rename in dialog.
  • I'd appreciate if I could do such a tag renaming in a semi-automatic way in the command line with tag.

Syntax and working principle

tag --change targetTag sourceTag1 [ sourceTag2 … source*tag*wildcard* … sourceTagX ]
  • There is no pathargument as renaming a tag (at least in Finder) is a global operation, which recursively changes all found tags of all files of all currently mounted volumes.
  • If targetTag is inexistent it gets created.
  • if targetTag exists, there's a warning, unless tag operates in a --forced or --yess (non-interactive) mode:
WARNING: The target tag "targetTag" already exists!
Do you want to merge your stated X source tag(s) into it? (y / n)

Design rationale behind argument nomenclature and order

  • --change and -c because the more appropriate --rename would have no short options as -r and -R are already taken.
  • targetTag as the first argument for usability/efficiency
    • because it is always required
    • whereas the sourceTag must be at minimum one or could also be multiple, so with the aid of command line history and autocompletion it is easier to have the longer / more likeable to be varying / copy'paste text snippet at the end of the command line where the cursor is by default then.

More advanced: targetTag can be static text plus integrating sourceTag via variable

  • targetTag can integrate $S into its string as a prefix, suffix or within. Examples:
    • tag --change 'MyPrefix $S' sourceTag1 [ sourceTag2 … source*tag*wildcard* … sourceTagX ]
    • tag --change '$S MySuffix' sourceTag1 [ sourceTag2 … source*tag*wildcard* … sourceTagX ]
    • tag --change '__ $S __' sourceTag1 [ sourceTag2 … source*tag*wildcard* … sourceTagX ]
  • Note: The dollar symbol within single quotes so that no shell variable resolving takes place and our app gets the "dollar S" literally for its special interpretation. Tags with this odd special symbol will result in errors. No need to support this with extra complicated escaping. Potentially affected users may choose more compatible Finder tag names. As this is already a niche product, that would be probably only 1 person in the next 50 years 😉.

Super advanced: targetTag can insert positional matches from single RegEx source tag

tag --change 'MyPrefix $2 - $1' 'singleRegexSourceTag---\d\d(\d\d)_(\d\d)'
  • Example: tag --change 'Finance $2 - $1' '(Business|Bookkeeping|Finance) (\d\d)_\d\d(\d\d)'
    • Business 07_2022 gets Finance 22_07
    • Bookkeeping 07_2022 gets Finance 22_07
    • Finance 08_2022 gets Finance 22_08

porg avatar Sep 27 '22 15:09 porg

I'd appreciate a reaction regarding this my proposal. Thanks!

porg avatar May 24 '23 22:05 porg