Created
January 22, 2017 23:06
-
-
Save djadriano/fba57969b6c4354469f4ea652a0e29eb to your computer and use it in GitHub Desktop.
Script for rename mp3 files and organize names
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
def adjust_file_name(str) | |
newEntry = str.downcase.gsub(/\w+/, &:capitalize) | |
newEntry = newEntry.gsub('.Mp3', '.mp3') | |
return newEntry | |
end | |
dirToFind = '/Users/adrianofernandes/Music/hardstyle/organized/renamed/euphoric/*' | |
arrItemsToFind = [ | |
'(Full)', | |
' [Hq + Hd Full]', | |
' [Hd+Hq][Full]', | |
' [Hd]', | |
' [Hd+Hq]', | |
' [Full Hq + Hd]', | |
' [Hq Hd]', | |
' [Hd + Hq]', | |
' [Hqhd]', | |
'-Ukhx', | |
' [Hq + Hd Free Download]', | |
' [Hd + Hq] [ Free Release]', | |
' [Hqhd]', | |
' [Hd + Hq][Full]', | |
' [Hq Original]', | |
' [Full][Tbt]', | |
' [Full Version] + [Hd] + [320kbps]', | |
' [Tbt]', | |
'[Free Release]', | |
' [Free Release]', | |
' [Hq Hd]', | |
' (Full Hq)', | |
' [Full Hq + Hd Version]', | |
' Full Hd[Www.mp3fiber.Com]', | |
' [Out Now!]', | |
' [Hd & Hq]', | |
' [Free]', | |
' [Full Hq + Hd Upcoming Free Release]', | |
' (Hd)', | |
' [Hqihd]', | |
' [Hq Free]', | |
' + [Hd] + [320kbps]', | |
' (Lyrics)', | |
' [Hd]', | |
'-ukhx', | |
'01-', | |
'01_', | |
'02-', | |
'02_', | |
'01 ', | |
'02 ' | |
] | |
Dir[dirToFind].each do |old| | |
if File.basename(old).include?('.mp3') | |
newEntry = old | |
if File.basename(old).include?('_') | |
newEntry = newEntry.gsub('_', ' ') | |
end | |
arrItemsToFind.each {|a| | |
if File.basename(old).include?(a) | |
newEntry = newEntry.gsub(a, '') | |
end | |
} | |
newEntry = adjust_file_name(newEntry) | |
File.rename(old, newEntry) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment