[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help copying files

Bob Miner

8/6/2008 10:35:00 PM

Hi,
I'm tryin to have Ruby copy some files so I don't have to :D

I can make the Directories, but apparently I need FTOOLS to actually
copy some files from hither to yon.

I can't seem to find FTOOLS.....anybody know where to get it? And
then....
where do I put it so Ruby can "see & use" it.

OR....

Is there a different/better way to copy files than FTOOLS?

I'm tryin to avoid actually opening EVERY FILE and loopin thru each line
writin into the new file......but I'm not above doin that ;)
--
Posted via http://www.ruby-....

3 Answers

Stefan Lang

8/6/2008 11:53:00 PM

0

2008/8/7 Bob Miner <bobminer@lobo.net>:
> Hi,
> I'm tryin to have Ruby copy some files so I don't have to :D
>
> I can make the Directories, but apparently I need FTOOLS to actually
> copy some files from hither to yon.
>
> I can't seem to find FTOOLS.....anybody know where to get it? And
> then....
> where do I put it so Ruby can "see & use" it.
>
> OR....
>
> Is there a different/better way to copy files than FTOOLS?

Use FileUtils:

require "fileutils"
FileUtils.cp src, dest

ri has lots of documentation about it!

Stefan

Lloyd Linklater

8/7/2008 3:55:00 PM

0

Here is a bit from Matz' book:

The copy method will copy a file to a new name or location. It has an
optional flag parameter to write error messages to standard error. The
UNIX-like name cp is an alias.

require "fileutils"

# Copy epsilon to theta and log any errors.
FileUtils.copy("epsilon","theta", true)
--
Posted via http://www.ruby-....

Bob Miner

8/9/2008 8:56:00 PM

0

Thanks....worked great!
--
Posted via http://www.ruby-....