Newbie-Script for copying matching files to new destination

O

Os Ai

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.
 
R

Robert Klemme

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
 
O

Os Ai

Robert said:
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?
 
R

Robert Klemme

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/001-Using_blocks_for_Robustness.html


Kind regards

robert
 
O

Os Ai

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
 
R

Robert Klemme

2009/5/14 Os Ai said:
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
 
O

Os Ai

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top