# directory listing to database

**URL:** <https://discuss.rubyonrails.org/t/directory-listing-to-database/73340>\
**Category:** rubyonrails-talk\
**Created:** [October 24, 2018, 2:42pm UTC](https://discuss.rubyonrails.org/t/directory-listing-to-database/73340 "2018-10-24T14:42:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fugee\_ohu](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/fugee_ohu/32/14370_2.png) [@fugee\_ohu](https://discuss.rubyonrails.org/u/fugee_ohu)\
**Post date:** [October 24, 2018, 2:42pm UTC](https://discuss.rubyonrails.org/t/directory-listing-to-database/73340/1 "2018-10-24T14:42:30Z")

</div>

I wanna copy directory listings from removable media to a database so then I’ll know what files are on what removable disk I’m thinking at the system level i have to list the directory to a file and then open the file for reading in ruby and then use the split function to parse each line as I iterate through Before I go ahead and do this is there another way?

---

<div class="post-metadata">

**Author:** ![Colin\_Law](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Colin\_Law](https://discuss.rubyonrails.org/u/Colin_Law)\
**Post date:** [October 24, 2018, 3:01pm UTC](https://discuss.rubyonrails.org/t/directory-listing-to-database/73340/2 "2018-10-24T15:01:40Z")

</div>

You could use one of the shell commands [1] which will give you back the directory listing direct to your code. No need for an intermediate file.

However, if you google for

ruby directory listing

it will show you much better ways. Usually google will be much quicker for asking such questions than here.

Colin

[1] [https://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby](https://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby)
