Created
December 28, 2015 17:43
-
-
Save isaiah/ee261b0eacba85d9d428 to your computer and use it in GitHub Desktop.
Replace file name with metadata
This file contains hidden or 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
require 'fileutils' | |
require 'taglib' | |
NAME = "©nam" | |
Dir.glob("./**/*.m4a").each do |f| | |
TagLib::MP4::File.open(f) do |mp4| | |
name = mp4.tag.item_list_map[NAME] | |
name = name.to_string_list.first | |
dir = File.dirname(f) | |
name = "#{dir}/#{name}.m4a" | |
FileUtils.mv(f, name) rescue nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment