Created
July 27, 2023 10:44
-
-
Save garlic0x1/1fe800e207b0dfee88c552d99c40e47b to your computer and use it in GitHub Desktop.
tag mp3s based on directory convention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import (garlic base) | |
(garlic sys) | |
(garlic strings)) | |
(define (tag-file dir file data) | |
(sh (string-append "id3v2 '" dir file "' -A " (car data) " -a " (cdr data)))) | |
(define (escape-unix-filename-spaces name) | |
(string-replace " " "\\ " name)) | |
(define (dir-album name) | |
(let* ([slash-split (string-split-all #\/ name)] | |
[short (last slash-split)] | |
[dot-split (string-split-all #\. short)] | |
[artist (car dot-split)] | |
[album (cadr dot-split)]) | |
(cons artist album))) | |
(define (tag-dir dir) | |
(->> (sh-lines (string-append "ls -a " dir)) | |
(stream-map (lambda (file) (tag-file dir file (dir-album dir)))) | |
(stream->list))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment