Skip to content

Instantly share code, notes, and snippets.

@stilist
Created December 18, 2009 01:02
Show Gist options
  • Save stilist/259179 to your computer and use it in GitHub Desktop.
Save stilist/259179 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -w
=begin
I had paths like:
entries/02009/December/01/x.rc
I wanted paths like:
entries/02009/December/01/text/x.rc
Code provided under the MIT license. Get a copy at
http://github.com/stilist/ratafiacurrant/blob/master/License
=end
require 'find'; require 'fileutils'
paths = []
file_list = []
File.expand_path('entries').each { |p|
Find.find(p) { |f|
if File.file?(f)
if 0 === (File.extname(f) =~ /\.rc\Z/) || 0 === (File.extname(f) =~ /\.mdown\Z/)
file_list << f
end
end
}
}
file_list.each { |f|
begin
paths << File.dirname(f)
rescue => err
puts "Error: #{err}"
end
}
paths.uniq!.each { |p|
FileUtils.mkdir_p(p + '/text/')
}
file_list.each { |f|
FileUtils.mv(f,
File.dirname(f) + '/text/' + File.basename(f))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment