2 simple file copying questions, please assist

All

I’d be grateful for someone’s assistance on the following (certainly) simple questions.
(Note that I’m running Ruby 1.8 Windows)

  1. I have a 2-line program with just this:

    require = "ftools"
    File.syscopy(“test.rb”, “test2.rb”)

    Running this returns the error “test33.rb:2: undefined method `syscopy’
    for File:Class (NoMethodError)”. What am I missing?

  2. The following code was recommended to me by Matz some time ago.
    What I want to know is, what do I replace <do_stuff_here> with
    to copy every file found under “some_directory” to single target directory,
    without reproducing the path structure. Result would be a single flat
    directory some_target. (Not controlling for possible file duplicate
    overwriting for the moment.)

    for f in Dir.glob("./some_directory/**/*")
    File.open(f) { |file|
    <do_stuff_here>
    }if File.file?(f)
    end

Much obliged!!!

-Kurt Euler

Try

require “ftools”

Regards,

Mark

···

On Saturday, October 4, 2003, at 01:43 AM, Kurt Euler wrote:

All

I’d be grateful for someone’s assistance on the following (certainly)
simple questions.
(Note that I’m running Ruby 1.8 Windows)

  1. I have a 2-line program with just this:

    require = “ftools”
    File.syscopy(“test.rb”, “test2.rb”)

[snip]

syscopy (in ‘ftools’ lib) can take a directory as its target
and copies the source files’ basename.

···

“Kurt Euler” keuler@portal.com wrote:

  1. The following code was recommended to me by Matz some time ago.
    What I want to know is, what do I replace <do_stuff_here> with
    to copy every file found under “some_directory” to single target directory,
    without reproducing the path structure. Result would be a single flat
    directory some_target. (Not controlling for possible file duplicate
    overwriting for the moment.)

    for f in Dir.glob(“./some_directory/**/*”)
    File.open(f) { |file|
    <do_stuff_here>
    }if File.file?(f)
    end

#------------

require “ftools”

TARGET = ‘C:/TEMP/rbcopies’ # target directory
Dir.mkdir(TARGET) unless File.directory?(TARGET)

for f in Dir.glob(“./some_directory/**/*”)
next unless File.file?(f)

check for exists? / read-only etc.

File.syscopy(f, TARGET)
end

#------------

daz