Last active
January 1, 2016 06:49
-
-
Save corny/8107152 to your computer and use it in GitHub Desktop.
A small Ruby script to remove private frames (PRIV) from ID3 tagged MP3 files.
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 | |
# | |
# Requirements (Ubuntu 14.04): | |
# apt-get install libid3-3.8.3-dev | |
# gem install id3lib | |
# | |
# Usage: | |
# ./id3_remove_private_frames.rb file1.mp3 file2.mp3 ... | |
# | |
require 'rubygems' | |
require 'id3lib' | |
updated = 0 | |
removed = 0 | |
begin | |
ARGV.each do |path| | |
tag = ID3Lib::Tag.new(path) | |
before = tag.length | |
tag.delete_if{ |frame| frame[:id] == :PRIV } | |
after = tag.length | |
print "#{path}: " | |
if before == after | |
puts "\e[32mno frames removed\e[0m" | |
else | |
diff = before-after | |
removed += diff | |
updated += 1 | |
tag.update! | |
puts "\e[31m#{diff} frames removed\e[0m" | |
end | |
end | |
rescue Interrupt | |
exit 1 | |
ensure | |
puts "#{removed} frames from #{updated} files removed" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment