From: Peter Smith Date: 2008-06-05T06:10:47+09:00 Subject: ruby reading files in many directories Hi, i have a question. I have a working script, that scans some txt files in a directory ,reads the lines and gives a few of that lines out in new files. But now, i wanted to scan the full subdirectorys for txt files. And copy some lines out of that files. The files are in different directorys belonging to the same subdirectory. for example \subdirectory1\txtdirectory1 \subdirectory1\txtdirectory2 \subdirectory1\txtdirectory3 \subdirectory2\txtdirectory1 \subdirectory2\txtdirectory2 \subdirectory2\txtdirectory3 and so on i used from wiki the example Dir['*.txt'].each do |txt| next unless File.file?(txt) but this only scans the same directory the ruby file is in. Now i changed this in Dir['/nameofdirectory/*.txt'].each do |txt| this doesnt work. then i tried Dir['*.txt'].each do |txt| next file.directory(".") At the end I also wanted to copy the processed files into a new directory. Its no problem with File.new("newfile", "w+") or file.new to make new datas, but i cant change the directory with file.open. the directory should be called converted or so on and should be in subdirectory1\converted ... I needed hours to get run the script in the same directory and spent also hors to get that run with different directorys. But i didnt finished the script. Thank for answers. Cheers Bastian -- Posted via http://www.ruby-forum.com/.