Forum: Ruby get files by its extension

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
16f82f5caa12038965397b3fd6ca3bec?d=identicon&s=25 ruby learner (idealone)
on 2009-04-13 06:19
Hi Guys,
         I want to download certain file types or certain files by its
name using ruby code.
example:
In Shell scripting, I can say cp *.txt, which inturn copies all files
with extension ".txt",
similarly i can say cp test* , all files with the string "test" are
copied.

  I want to achieve similar tasks using ruby code, as i am novice using
ruby.
My purpose is that i am connecting to my Linux server through ftp and
trying to download files with certain extension.
Let me know if any more info is required from my end


cheers
Thanks in Advance
6b46f4eed76df33a3ffacf87bc9f1079?d=identicon&s=25 vimal (Guest)
on 2009-04-13 07:30
(Received via mailing list)
On Apr 13, 9:19 am, Idealone Ideally <sheka...@gmail.com> wrote:
> ruby.
> My purpose is that i am connecting to my Linux server through ftp and
> trying to download files with certain extension.
> Let me know if any more info is required from my end
>
> cheers
> Thanks in Advance
> --
> Posted viahttp://www.ruby-forum.com/.

Dir.glob('*.txt')

Regards,
Vimal Das
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2009-04-13 13:55
(Received via mailing list)
On 13.04.2009 07:29, vimal wrote:
>>   I want to achieve similar tasks using ruby code, as i am novice using
>> ruby.
>> My purpose is that i am connecting to my Linux server through ftp and
>> trying to download files with certain extension.
>> Let me know if any more info is required from my end

> Dir.glob('*.txt')

Does not work with FTP directories.  Rather look at Net::FTP:

http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/index.html

Especially method #nlst

http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/cla...

Kind regards

  robert
6b46f4eed76df33a3ffacf87bc9f1079?d=identicon&s=25 vimal (Guest)
on 2009-04-14 07:10
(Received via mailing list)
On Apr 13, 4:50 pm, Robert Klemme <shortcut...@googlemail.com> wrote:
> >> with extension ".txt",
> >> similarly i can say cp test* , all files with the string "test" are
> >> copied.
>
> >>   I want to achieve similar tasks using ruby code, as i am novice using
> >> ruby.
> >> My purpose is that i am connecting to my Linux server through ftp and
> >> trying to download files with certain extension.
> >> Let me know if any more info is required from my end
> > Dir.glob('*.txt')
>
Sorry for the intervention guys, i didn't get your question properly.

Regards,
Vimal Das
This topic is locked and can not be replied to.