Skip to content

Instantly share code, notes, and snippets.

@randy909
Last active May 30, 2016 12:49
Show Gist options
  • Save randy909/eaa83b2929ae3dae5d794bf60e5ed0a1 to your computer and use it in GitHub Desktop.
Save randy909/eaa83b2929ae3dae5d794bf60e5ed0a1 to your computer and use it in GitHub Desktop.
Dir.glob('*.mp3') do |file|
front, num, back = file.match(/^(.+\()(\d+)(\).+)/).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