# File Iteration

**URL:** <https://www.ruby-forum.com/t/file-iteration/159309>\
**Category:** Rails\
**Created:** [February 3, 2009, 11:43am UTC](https://www.ruby-forum.com/t/file-iteration/159309 "2009-02-03T11:43:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 3, 2009, 11:43am UTC](https://www.ruby-forum.com/t/file-iteration/159309/1 "2009-02-03T11:43:02Z")

</div>

Hi all…  
i have folder named test in my application’s public folder .  
i want to iterate that folder named test which is in public folder.  
for that i tried this code it gives me error like

Errno::ENOENT

```
in Chat logController#chat_log

```

```
No such file or directory - /public/ACMServer_exe/ChatHistory
```

`RAILS_ROOT:
D:/Projects/inProgress/ANGACM0908/re/Task/acm_administration-31-jan-09`\</p so how should i iterate the folder test which is in public folder

Thanks

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 3, 2009, 12:00pm UTC](https://www.ruby-forum.com/t/file-iteration/159309/2 "2009-02-03T12:00:47Z")

</div>

On 3 Feb 2009, at 10:43, Newb N. wrote:

> Hi all…  
> i have folder named test in my application’s public folder .  
> i want to iterate that folder named test which is in public folder.  
> for that i tried this code it gives me error like

What code 🙂 ? Dir.each, Dir.glob, Dir.entries can all be useful for  
this sort of thing.

Fred

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 3, 2009, 12:11pm UTC](https://www.ruby-forum.com/t/file-iteration/159309/3 "2009-02-03T12:11:56Z")

</div>

try this

Dir.foreach(RAILS\_ROOT + ‘/public/javascripts’) do |filename|  
puts filename  
end

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 3, 2009, 12:06pm UTC](https://www.ruby-forum.com/t/file-iteration/159309/4 "2009-02-03T12:06:44Z")

</div>

Frederick C. wrote:

> On 3 Feb 2009, at 10:43, Newb N. wrote:
> 
> > Hi all…  
> > i have folder named test in my application’s public folder .  
> > i want to iterate that folder named test which is in public folder.  
> > for that i tried this code it gives me error like
> 
> What code 🙂 ? Dir.each, Dir.glob, Dir.entries can all be useful for  
> this sort of thing.
> 
> Fred

Dir.foreach("/ACMServer\_exe") do |folder\_name|

does this code is correct.  
but it gives me error.  
=\> this folder is in public folder =\> ACMServer\_exe

pls help me
