DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Malfromed Split Archive Fix

12.31.2008
| 1891 views |
  • submit to reddit
        Fix a malformed split archive

Turns files name *.001, *.002, *.003 into *.r01, *.r02, *.r03
require 'fileutils'
Dir.entries(File.dirname(__FILE__)).each { FileUtils.mv(File.join(File.dirname(__FILE__), entry), File.join(File.dirname(__FILE__), entry.gsub!(/\.(0)(\d+)\z/, '.r\2')), :verbose => true) if entry[/\.(0)(\d+)\z/]}