Skip to content

Instantly share code, notes, and snippets.

@yoni
Created August 14, 2013 02:42
Show Gist options
  • Save yoni/6227583 to your computer and use it in GitHub Desktop.
Save yoni/6227583 to your computer and use it in GitHub Desktop.
Converts R filenames from camel case to snake case.
#!/usr/bin/env ruby -n
name = $_
if name != name.upcase
puts "mv #{name.chomp} #{name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase.gsub('.r', '.R').gsub('r/','R/')}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment