TMSU icon indicating copy to clipboard operation
TMSU copied to clipboard

feature request: “tmsu value TAG FILE”

Open val461 opened this issue 7 years ago • 5 comments

Hello, I currently use the following trick from the wiki to show the tags of many files: $ tmsu files QUERY | xargs tmsu tags

I think a command value should be added, to allow doing things like: $ tmsu files QUERY | xargs tmsu value TAG

This could be helpful because I sometimes want to compare the values of just one tag over many files, but the first command above gives me a lot of irrelevant output, because my files have many tags.

For example, the new feature could go like this:

$ tmsu files song | xargs tmsu value year
song1.ogg: 2004
song2.ogg: 2017
song3.ogg: 2149

val461 avatar Jun 25 '18 13:06 val461

Could you not use:

$ tmsu file song | xargs tmsu tags | grep -o "year=\w\+"

Or is that too unwieldy or slow?

oniony avatar Aug 29 '18 21:08 oniony

OK, above works but omits the filenames, so obviously is a bit crap. Perhaps the proposed value subcommand makes sense.

oniony avatar Aug 29 '18 21:08 oniony

Actually, you could match both the filename and the tag, but it's even more obtuse:

$ tmsu files song | xargs tmsu tags | grep -o -e "^.*: " -e "year=\w\+"

oniony avatar Aug 29 '18 21:08 oniony

Thanks for the tip!

val461 avatar Aug 30 '18 18:08 val461

@oniony : that should be egrep -oe "^(.*)[^\\]: " -e "year=\w\+" , since a) 0-length filenames should never exist on disk or be output by tmsu, and b) the string ": " may exist in the filename or in a tag, which is rendered as \: when in a filename, and such strings should not be treated as a match. -- Department of Regexp Paranoia ;)

0ion9 avatar Jan 06 '20 23:01 0ion9