IdEst |
|
ID3 Editing and Scripting Tool |
Sergey Poznyakoff |
This section illustrates how to write scripts that modify ID3 tags.
We will write a script which creates a new value for the ‘title’
(TIT2
) frame from the name of the input file. The title is
created using the following algorithm:
Here is the implementation:
;; settitle.scm - set title (TIT2) frame based on ;; the file name. (use-modules (ice-9 regex) (srfi srfi-13)) (define (idest-main file frames) (cond ((string-match "(.*)\\.mp3" file) => (lambda (match) (cons (cons "TIT2" (list (cons 'text (string-map (lambda (c) (if (char=? c #\_) #\space c)) (match:substring match 1))))) ;; (filter (lambda (elt) (not (string=? (car elt) "TIT2"))) frames)))) (else #f))) (set! idest-readonly #f)
An example of using this script on all files in the current directory:
$ idest --script settitle *.mp3
This document was generated on March 11, 2017 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.