Skip to content

b4winckler/tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tag

tag is a simple command line audio tag editor. It can view and modify tags for any tag format recognized by TagLib (e.g. ID3v1 and ID3v2 for MP3 files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC, Speex, WavPack TrueAudio, WAV, AIFF, MP4 and ASF files).

Usage

By default tag will print all audio tags it recognizes

$ tag file.flac
artist:  Kyuss
album:   Muchas Gracias
title:   Un Sandpiper
track:   1
year:    1997
genre:   Rock
comment: Track 1

If you specify more than one input file, then the tag for each file will be printed one at a time.

The second operation of tag is to modify audio tags

$ tag file.flac --genre 'Stoner Rock' --year 2000
$ tag file.flac
artist:  Kyuss
album:   Muchas Gracias
title:   Un Sandpiper
track:   1
year:    2000
genre:   Stoner Rock
comment: Track 1

Note that arguments are subject to shell interpretation so be sure to put single quotes around arguments with spaces etc.

If no file name arguments are specified then a list of tab-separated values (TSV) are read from stdin. Each line is a record consisting of a path to an audio file as well as the tags that should be set on that file. The exact format can be seen by adding the --tsv option when printing tags. The combination of the --tsv flag and not specifying any file arguments enables tag to be used with an external filter. For example

tag --tsv *.flac | awk 'BEGIN{FS=OFS="\t"} { ... }' | tag

Here ... could be any valid awk code, e.g. it could look at the file path in order to set track number and song title. Note that tag does not check for tab characters in audio tags or file paths. The presence of tab characters in audio tags would cause the above example to silently fail. In other words, tag --tsv file | tag will not modify the tags in file unless one or more of them contain tab characters.

See tag --help for a list of supported options.

Examples

  • Set album name of all files in current folder (note that a file without a tag will be ignored):

    tag * --album Requiem
    

    A tag with spaces or other characters that will be interpreted by the shell need to be protected by single quotes, e.g.:

    tag * --album 'Mozart - Requiem'
    

    If the tag contains a single quote then you can use double quotes:

    tag * --album "Mozart's Requiem"
    

    If a tag contains both double and single quotes then it needs to be escaped like this (assuming you are using the bash shell):

    tag * --album 'Mozart'\''s "Requiem"'
    
  • Recursively set genre of all songs in folder Classical (note that tag will ignore folders and any non-music files, such as cover art etc.):

    find Classical -exec tag --genre Classical {} +
    
  • Recursively find artist for all songs under current folder, then print how many songs each artist has in decreasing order (this may take a while if you have a large library):

    find . -exec tag {} + | grep 'artist:' | \
         sed -e 's/artist://' | sort | uniq -c | sort -bnr
    
  • Remove (OST) from the album title of all flac files in the current directory:

    tag --tsv *.flac | \
         awk 'BEGIN{FS=OFS="\t"} {sub(" (OST)", "", $4); print}' | tag
    
  • Find all flac files without a genre tag and log their names to the file missing-genre.txt:

    find . -name '*.flac' -exec tag --tsv {} + | \
        awk -F'\t' '$6==""{print $1}' > missing-genre.txt
    
  • Print the names of directories which contain flac files without a genre tag:

    find . -name '*.flac' -exec tag --tsv {} + | \
        awk -F'\t' '$6==""{sub("/[^/]*$", "", $1); print $1}' | uniq
    

Scripts

The scripts folder contains more examples on how to use tag. For example, tag-using-path can be used to set the track number and song title for all flac files in a folder based on file names.

Known bugs

It is not possible to:

  • edit any other tags than the ones output by tag filename,
  • delete tags or specify empty tags (e.g. it is only possible to clear the comment tag by tag file --comment ' '),
  • add tags to a file without tags.

Installation

Assuming you have the Haskell Platform and TagLib installed:

$ cabal install

About

Simple command line audio tag editor

Resources

License

Stars

Watchers

Forks

Packages

No packages published