Show all files from a folder

I can not find nothing about files in google,
how to create delete, how to show all files from a folder

if you can redirect me to some web site I’d appreciate
thanks

On Mar 1, 2006, at 1:43 PM, misiek wrote:

I can not find nothing about files in google,
how to create

File.open(“my_file.txt”, “w”) { |f| f.puts “A line in the file.” }

delete

File.unlink “my_file.txt”

how to show all files from a folder

puts Dir[“path/to/dir/*”]

if you can redirect me to some web site I’d appreciate

Try browsing through the methods of File and Dir in the docs:

http://www.ruby-doc.org/core/

Hope that helps.

James Edward G. II

“misiek” [email protected] wrote in message
news:[email protected]

I can not find nothing about files in google,
how to create delete, how to show all files from a folder

if you can redirect me to some web site I’d appreciate
thanks

Here’s the website I use:
http://www.rubycentral.com/ref/

Check out Dir and File

Here’s some sample code I’ve been tinkering with that should get you
started.

def findDirs (thisDir)
Dir.entries(thisDir).each { |x|
next if [ “.” , “…” ].include? x
thisFile = File.join(thisDir,x)
case File.ftype(thisFile)
when “directory”
puts "Found a directory: "+thisFile
findDirs(thisFile)
when “file”
#puts "Found a file! "+File.join(thisDir, x)
end
}
end

DirHelper.new.findDirs(ARGV[0])
end

Jared
http://JaredRichardson.net

thank you all of you for help :slight_smile:

Try Dir and File:

my_dir = Dir[“C:/workspaces/Source/**/*.rb”] # collect all the
ruby files recursively
my_dir.each do |filename|
puts filename
File.open(filename, “r”) do |f|
puts f
end
end

Here’s a good place to start:

http://ruby-doc.org/docs/ProgrammingRuby/

Look for Dir and File.

-Tom

How can I display the content of a folder after some time of its
creation, in order to see the newly added files?
Any script with File.readlines? any help?

James G. wrote:

On Mar 1, 2006, at 1:43 PM, misiek wrote:

I can not find nothing about files in google,
how to create

File.open(“my_file.txt”, “w”) { |f| f.puts “A line in the file.” }

delete

File.unlink “my_file.txt”

how to show all files from a folder

puts Dir[“path/to/dir/*”]

if you can redirect me to some web site I’d appreciate

Try browsing through the methods of File and Dir in the docs:

RDoc Documentation

Hope that helps.

James Edward G. II