Forum: Ruby Newbie-Script for copying matching files to new destination

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.
Os A. (Guest)
on 2009-05-13 21:20
Hi,
Being new to Ruby,am not sure if it can do these but if it can then
someone please help.My challenge is that I want to copy certain files
from a source location with filenames containing words listed in a text
file to a new location. Any help would be most appreciated.Thanks in
advance.
Robert K. (Guest)
on 2009-05-13 22:36
(Received via mailing list)
On 13.05.2009 19:21, Os Ai wrote:
> Being new to Ruby,am not sure if it can do these but if it can then
> someone please help.My challenge is that I want to copy certain files
> from a source location with filenames containing words listed in a text
> file to a new location. Any help would be most appreciated.Thanks in
> advance.

I am not sure what you are asking for...  How about:

1. read words from file
2. enumerate all files in the source location and check each name for a
match
3. if there is a match copy the file from source to target

Cheers

  robert
Os A. (Guest)
on 2009-05-13 22:43
Robert K. wrote:
> On 13.05.2009 19:21, Os Ai wrote:
>> Being new to Ruby,am not sure if it can do these but if it can then
>> someone please help.My challenge is that I want to copy certain files
>> from a source location with filenames containing words listed in a text
>> file to a new location. Any help would be most appreciated.Thanks in
>> advance.
>
> I am not sure what you are asking for...  How about:
>
> 1. read words from file
> 2. enumerate all files in the source location and check each name for a
> match
> 3. if there is a match copy the file from source to target
>
> Cheers
>
>   robert

Hi Robert,
Yes you got it. I guess you know how to speak 'programming' which I
obviously don't.So how do I go about it?
Robert K. (Guest)
on 2009-05-13 23:15
(Received via mailing list)
On 13.05.2009 20:43, Os Ai wrote:
>> 2. enumerate all files in the source location and check each name for a
>> match
>> 3. if there is a match copy the file from source to target

> Yes you got it. I guess you know how to speak 'programming' which I
> obviously don't.So how do I go about it?

Assuming you are completely new to programming you probably want to
start here http://pine.fm/LearnToProgram/ or with any other introductory
tutorial for Ruby and then look up documentation about these core and
standard library classes

String
Array
File
Dir
Find

You'll find it here http://www.ruby-doc.org/core-1.9/index.html and
http://www.ruby-doc.org/stdlib/.  You can also find some hints about
file reading in our blog, although I suggest you first consider Chris's
book:

http://blog.rubybestpractices.com/posts/rklemme/00...


Kind regards

  robert
Os A. (Guest)
on 2009-05-14 02:24
Hi Robert,
Thanks for even taking time to write and even advice.Am indeed
grateful.I would research on all the literature since am new to Ruby.I
would still like to be guided on how to go about it as I need it
urgently.Thanks
Robert K. (Guest)
on 2009-05-14 12:12
(Received via mailing list)
2009/5/14 Os Ai <removed_email_address@domain.invalid>:
> Thanks for even taking time to write and even advice.Am indeed
> grateful.I would research on all the literature since am new to Ruby.I
> would still like to be guided on how to go about it as I need it
> urgently.Thanks

Learning and urgency do not mix well.  If you are new to programming
you cannot expect to learn it overnight.

This forum is generally very helpful, however to me it feels like this
question has "do my (home) work for me" written all over it.  You have
not demonstrated that you followed advice given or what you attempted
yourself yet expect "guidance" and try to push us.  This usually does
not work well with volunteers.  For more elaborate explanations please
read:

http://catb.org/esr/faqs/smart-questions.html#urgent

Regards

robert
Os A. (Guest)
on 2009-05-15 11:43
Thanks for your post. You have raised very valid points. I am learning
and hopefully would be able to find a solution in a few days. Thanks
again.
This topic is locked and can not be replied to.