Skip to content

Instantly share code, notes, and snippets.

@linus-young
Created September 26, 2013 15:13
Show Gist options
  • Save linus-young/6715579 to your computer and use it in GitHub Desktop.
Save linus-young/6715579 to your computer and use it in GitHub Desktop.
Change all .txt file in one directory to .cpp file.
require 'fileutils'
Dir.glob('/path_to_file_directory/*.txt').each do |f|
FileUtils.mv f, "#{File.dirname(f)}/#{File.basename(f,'.*')}.cpp"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment