Last active
May 30, 2016 12:49
-
-
Save randy909/eaa83b2929ae3dae5d794bf60e5ed0a1 to your computer and use it in GitHub Desktop.
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
Dir.glob('*.{mp3,MP3}') do |file| | |
match = file.match(/^(.+\()(\d+)(\).+)/) | |
if (match == nil) | |
puts "skipping #{file}" | |
next | |
end | |
front, num, back = match.captures | |
num = num.rjust(2, '0') | |
newfile = front + num + back | |
puts "renaming #{file} to #{newfile}" | |
File.rename(file, newfile) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment