# Watch Folder for New Files

**URL:** <https://www.ruby-forum.com/t/watch-folder-for-new-files/72547>\
**Category:** Rails\
**Created:** [October 18, 2006, 12:18am UTC](https://www.ruby-forum.com/t/watch-folder-for-new-files/72547 "2006-10-18T00:18:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim\_dandy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jim\_dandy](https://www.ruby-forum.com/u/jim_dandy)\
**Post date:** [October 18, 2006, 12:18am UTC](https://www.ruby-forum.com/t/watch-folder-for-new-files/72547/1 "2006-10-18T00:18:56Z")

</div>

I’ve got an application that needs to take action when new files appear  
in a directory.

From a rails application, what would the easiest/best way to implement  
this be?

When a new file appears, I’ll need to call an action on a controller  
with the filename.

Any ideas much appreciated.

Regards,  
JD

---

<div class="post-metadata">

**Author:** ![jim\_dandy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jim\_dandy](https://www.ruby-forum.com/u/jim_dandy)\
**Post date:** [October 18, 2006, 12:35am UTC](https://www.ruby-forum.com/t/watch-folder-for-new-files/72547/2 "2006-10-18T00:35:00Z")

</div>

> I’ve got an application that needs to take action when new files appear  
> in a directory.
> 
> From a rails application, what would the easiest/best way to implement  
> this be?
> 
> When a new file appears, I’ll need to call an action on a controller  
> with the filename.
> 
> Any ideas much appreciated.

How quickly does it need to be acted on? If one minute intervals are  
okay, setup a cron job to run a script via script/runner to process any  
files in that directory.

Otherwise look at using backgrounddrb to notify that a file has been  
deposited and needs processing…

-philip
