Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to rename tags themselves #69

Open
porg opened this issue Sep 27, 2022 · 1 comment
Open

Possibility to rename tags themselves #69

porg opened this issue Sep 27, 2022 · 1 comment

Comments

@porg
Copy link

porg commented Sep 27, 2022

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
Copy link
Author

porg commented May 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant