.TL Bulk-Edit Vorbis Metadata .AU tropf .AB A simple hack to bulk edit metadata of vorbis files using scripts. .AE .DA . .NH 1 Usecase .PP I regularly scrape or download music from a variety of sources. These sources usually provide metadata which follows a certain schema – but not my schema. .PP So it is not uncommon that i wan't to transform some schema of metadata to another. .PP This article will use the convention of providing the license as URL in den .CW "copyright" data field: . .CB [...] copyright=http://creativecommons.org/licenses/by-nc-nd/3.0/ [...] .CE . .PP I personally prefer a human readable string, so I would use: . .CB [...] LICENSE=CC-BY-ND 3.0 [...] .CE . .NOTE I also use a different key. . .NH 1 Metadata of Vorbis Files .NH 2 Data Structure .PP Metadata of vorbis files is a list of strings of the form .CW "key=value" "." .PP Even though the keys are case sensitive, most programs handling vorbis files .B "don't care" and can handle lower and upper case spelling. . .NH 2 Editing Metadata .PP A simple way to edit metadata of vorbis files is using the program .CW "vorbistagedit" "." When invoked by .CW "vorbistagedit FILE" it will open an editor with a temporary file looking like this: . .CB # vorbistagedit ($Id$) # # Edit the lines in this file to your desire, but # DO NOT touch lines starting with a colon (:)! # You may use lines starting with a plus (+) to rename files. # # We are in directory: # /tmp # # Tags that should be applied to all files can be specified # before the first per-file tag definiton starts. : Carter_Vail_-_Veltvet.ogg + Carter_Vail_-_Veltvet.ogg TITLE=Veltvet ARTIST=Carter Vail TRACKNUMBER=6 DATE=2019 COMPOSER=Carter Vail LABEL=http://www.jamendo.com ENCODEDBY=Jamendo:http://www.jamendo.com| LAME LICENSE=CC-BY-NC-ND 3.0 : EOF .CE .PP You can then edit, save and close the file and your changes will be applied. . .NH 1 Editing by Script .NH 2 Concept .PP The basic idea is instead of invoking an interactive editor a script is executed on the file. .PP .CW "vorbistagedit" executes .CW "$EDITOR TMPFILENAME". We just have to change .CW "$EDITOR" to a script accepting a filename as one argument and changes that file. .NOTE Obviously I will use .CW "sed" with the .CW "-i" flag. . .NH 2 Example .CB EDITOR='sed -i -E -e "/^license|LICENSE/d" -e "s,^copyright=http://creativecommons.org/licenses/([^/]+)/([^/]+)/,&\enLICENSE=CC-\eU\e1\eE \e2,gi"' vorbistagedit Carter_Vail_-_Veltvet.ogg .CE . .NH 1 See also .PP .ULS .LI .B vorbistagedit (1): program used to edit the tags .LI .B sed (1): program i used to manipulate the file .ULE