Advait Bellur
2007-Aug-24 05:26 UTC
How to find the full path of a file in a present in a direct
Hi, I need to know how to determine the full path of o file which is present in a directory. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dima
2007-Aug-24 08:44 UTC
Re: How to find the full path of a file in a present in a direct
File.expand_path(item) if File.exist?(item) && File.file?(item) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Advait Bellur
2007-Aug-24 10:12 UTC
Re: How to find the full path of a file in a present in a di
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Bellur
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---