From: Igor Pirnovar Date: 2012-10-29T03:46:52+09:00 Subject: Re: Passing folder as argument ARGV? Joz Private wrote in post #1081694: > Thanks guys. > > Is each file in the directory given its own element in ARGV, is there > one element ARGV[0] that corresponds to the directory itself? p Dir["#{File.expand_path(ARGV[0])}/*"].each.map { |f| File.basename(f) } With the above code you can give the folder name to your program, like the following: $ ruby get_files.rb folder_name Use {{ p ARGV }} or {{ puts ARGV }} to see what is in it. If you run the above {{ $ ruby get_files.rb }} in the terminal or console on the command line then ARGV[0] will have in it the string 'folder_name'. If you run {{ $ ruby get_files.rb *.rb }}, each element in the ARGV array will have one file from your current directory. -- Posted via http://www.ruby-forum.com/.