mingw版の Gauche でも動いた。
良く考えたらパイプが動いていない予感。
gauche.charconv を使った方が良さそうだ。
#!/usr/bin/gosh (use gauche.process) (use srfi-1) (use util.list) ;; requirements ;; nkf ;; id3tool ;; ffmpeg ;; oggenc (define (basename path) (let ((match (#/(.+)\..+$/ (sys-basename path)))) (if match (match 1) (sys-basename path)))) (define (id3 mp3) (map (lambda (m) (cons (m 1) (m 2))) (filter-map #/([^:]+):\s*(.+?)\s+$/ (process-output->string-list (format "id3tool ~s | nkf -w" mp3))))) ; needed nkf -S? (define (mp3->ogg mp3-path) (let* ((mp3 (id3 mp3-path)) (artist (assoc-ref mp3 "Artist")) (title (assoc-ref mp3 "Song Title")) (tmp-file "./tmp.wav")) (sys-system (format "ffmpeg -y -i ~s ~a" mp3-path tmp-file)) (sys-system (format "oggenc ~s -o ~s --artist=~s --title=~s" tmp-file (string-append (basename mp3-path) ".OGG") artist title)) (sys-unlink tmp-file))) (for-each (lambda (file) (mp3->ogg (format "~a.mp3" file))) (remove (lambda (file) (sys-access (format "~a.OGG" file) R_OK)) (map (cut <> 1) (filter-map #/(.+)\.mp3$/ (sys-readdir ".")))))