Skip to content

Instantly share code, notes, and snippets.

@isaiah
Created December 28, 2015 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaiah/ee261b0eacba85d9d428 to your computer and use it in GitHub Desktop.
Save isaiah/ee261b0eacba85d9d428 to your computer and use it in GitHub Desktop.
Replace file name with metadata
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