# How to find the full path of a file in a present in a direct

**URL:** <https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897>\
**Category:** Rails\
**Created:** [August 24, 2007, 7:26am UTC](https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897 "2007-08-24T07:26:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [August 24, 2007, 7:26am UTC](https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897/1 "2007-08-24T07:26:03Z")

</div>

Hi,

I need to know how to determine the full path of o file which is present  
in a directory.

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [August 24, 2007, 10:45am UTC](https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897/2 "2007-08-24T10:45:12Z")

</div>

File.expand\_path(item) if File.exist?(item) && File.file?(item)

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [August 24, 2007, 12:12pm UTC](https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897/3 "2007-08-24T12:12:42Z")

</div>

dima wrote:

> File.expand\_path(item) if File.exist?(item) && File.file?(item)

Thank you very much, but this is only for one file I suppose…I want  
to determine the full path of multiple files which are present in a  
particular directory.

And " item " in the above code is the file name I suppose.

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [August 24, 2007, 2:15pm UTC](https://www.ruby-forum.com/t/how-to-find-the-full-path-of-a-file-in-a-present-in-a-direct/112897/4 "2007-08-24T14:15:47Z")

</div>

items\_full\_path = []  
Dir.new(“.”).entries.each do |item|  
items\_full\_path \<\< File.expand\_path(item) if File.exist?(item) &&  
File.file?(item)  
end

On Aug 24, 12:12 pm, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
