Skip to content

Instantly share code, notes, and snippets.

@christonog
Created November 16, 2011 03:15
Show Gist options
  • Select an option

  • Save christonog/1369146 to your computer and use it in GitHub Desktop.

Select an option

Save christonog/1369146 to your computer and use it in GitHub Desktop.

Revisions

  1. christonog created this gist Nov 16, 2011.
    30 changes: 30 additions & 0 deletions file_create.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    =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