Help copying files

B

Bob Miner

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 ;)
 
S

Stefan Lang

2008/8/7 Bob Miner said:
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
 
L

Lloyd Linklater

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)
 

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,781
Messages
2,569,615
Members
45,297
Latest member
EngineerD

Latest Threads

Top