Created
December 7, 2013 22:20
-
-
Save maruks/7850031 to your computer and use it in GitHub Desktop.
WAV->FLAC encoding/tagging script
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
!/usr/bin/env ruby | |
if ARGV.length < 4 | |
puts "Usage: enc-flac artist year album picture" | |
exit | |
end | |
artist = ARGV[0] | |
date = ARGV[1] | |
album = ARGV[2] | |
picture = ARGV[3] | |
unless File.file?(picture) | |
puts "picture file #{picture} not found" | |
exit | |
end | |
puts "artist: #{artist}" | |
puts "date: #{date}" | |
puts "album: #{album}" | |
puts "picture: #{picture}" | |
def encode (file, artist, date, album, picture) | |
match = file.match /(\d+)\s+([^\.]+)\.wav/ | |
if match | |
num = match[1].to_i | |
title = match[2] | |
tags = "-T TITLE=\"#{title}\" -T TRACKNUMBER=#{num} -T DATE=\"#{date}\" -T ALBUM=\"#{album}\" -T ARTIST=\"#{artist}\" -T ALBUMARTIST=\"#{artist}\"" | |
cmd = "flac --picture \"#{picture}\" #{tags} --best \"#{file}\"" | |
puts cmd | |
res = %x[ #{cmd} ] | |
puts res | |
else | |
puts "NO MATCH #{file}" | |
end | |
end | |
files = Dir.entries(Dir.pwd) | |
files.each{ |f| encode(f, artist, date, album, picture) if File.file?(f) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment