Created
November 17, 2010 04:31
-
-
Save elitecoder/702975 to your computer and use it in GitHub Desktop.
Change Names of MP3 Song Files (present in a directory) using Tag Information. [For Win32]
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
############################################### | |
# Screenshot.rb # | |
# Author: Mukul Sharma # | |
# Date: 11/09/2009 # | |
############################################### | |
require 'rubygems' | |
require 'id3lib' | |
# Load a tag from a file | |
# tag = ID3Lib::Tag.new(ARGV[0]) | |
fnames = [] | |
fpath = [] | |
path = [] | |
check = 0 | |
num = 0 | |
record = `dir /b /S *.mp3`.chomp! | |
fnames = record.split("\n") | |
fnames.each { |p| | |
fpath = p.to_s.split('\\') | |
fpath.slice!(fpath.size-1) | |
path << fpath.join('\\') | |
} | |
def fileTail (file, offset) | |
f=File.new(file) | |
f.seek(-offset,IO::SEEK_END) | |
tag,title,artist,album,year,comment,genre= | |
f.read.unpack "A3A30A30A30A4A30C" | |
raise "No ID3 Info" if tag!='TAG' | |
f.close | |
return title | |
end | |
count = 0 | |
while (count < fnames.size) | |
title = fileTail("#{fnames[count]}", 128) | |
File.rename("#{fnames[count]}", "#{path[count]}"+"\\"+"#{title}"+".mp3") | |
count += 1 | |
puts "." | |
end | |
puts "Processed #{count} Files in all." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment