Skip to content

Instantly share code, notes, and snippets.

@christonog
Created November 16, 2011 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christonog/1369146 to your computer and use it in GitHub Desktop.
Save christonog/1369146 to your computer and use it in GitHub Desktop.
Ruby file creation script
=begin
first edition: 11/15/2011
I created this script in order to help me create files with the same extension quickly. It's not too powerful, but gets
the job done and can be somewhat customized to suit the needs of the user (granted if they can code in ruby)
Hope it helps!
-Chris
=end
puts "This is a quick and dirty ruby script to create files quickly in the present working directory"
puts "How many files do you want to create?"
file_count = gets.chomp().to_i
puts "what is the name of the file? For example, the 'file' in file.doc."
name = gets.chomp()
puts "what is the extension of the files? Sorry, it can only be one extension type (eg .doc)."
file_extension = gets.chomp()
for i in 1..file_count
filename = "#{name}#{i}#{file_extension}"
file = File.open(filename, 'a')
file.write(filename)
file.close()
puts "#{filename} was created"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment