Created
September 1, 2014 16:58
-
-
Save karthiks/30d8606eab562e81e83f to your computer and use it in GitHub Desktop.
To set the title metadata tag of a media file to that of its base_file_name
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 | |
puts "Starting.." | |
require 'taglib' | |
#Dir['path/to/dir/*'].select { |e| File.file?(e) } | |
Dir.glob("./*.wma").each do |filename| | |
puts "File name: #{filename}" | |
TagLib::FileRef.open(filename) do |f| | |
title = File.basename(filename, ".*") | |
tag = f.tag | |
print "\t BEFORE: Title: #{tag.title} \n" | |
f.tag.title = title | |
f.save | |
print "\t AFTER: Title: #{title} \n" | |
end | |
end | |
puts "The End!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment