Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'active_support/core_ext/string'
- if ARGV.size < 2
- puts "#{$0} old_string new_string"
- puts "example: #{$0} problem_set contest"
- exit
- end
- renames = { ARGV[0] => ARGV[1], ARGV[0].camelcase => ARGV[1].camelcase }
- # directory names, file names, file content
- [ 'd', 'f' ].each { |p| renames.each { |f, t| system " rename #{f} #{t} `find \\( ! -regex '.*/\\..*' \\) -type #{p}` " } }
- renames.each { |f, t| system "find \\( ! -regex '.*/\\..*' \\) -type f | while read f; do sed -i 's/#{f}/#{t}/g' $f; done" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement