K
Kurt Euler
daz (or anyone)-
Thanks for your suggestion way below. It looks very promissing, but it seems I'm having momentary permissioning problems on my NT machine. Please assist if you can. When I run this code...
require 'ftools'
TARGET = 'C:/test/rbcopies' # target directory
Dir.mkdir(TARGET) unless File.directory?(TARGET)
for f in Dir.glob("./**/*")
next unless File.file?(f)
#
# check for exists? / read-only etc.
#
File.syscopy(f, TARGET)
end
... I get this error:
test44.rb:3:in `mkdir': No such file or directory - C:/test/rbcopies (Errno::ENOENT)
from test44.rb:3
When I change the drive letter in TARGET (line 2) from C: to D:, I get this error:
c:/ruby/lib/ruby/1.8/ftools.rb:23:in `initialize': Permission denied - D:/test/rbcopies/PJF_AppCenter_FnS.doc (Errno::EACCES)
from c:/ruby/lib/ruby/1.8/ftools.rb:23:in `open'
from c:/ruby/lib/ruby/1.8/ftools.rb:23:in `syscopy'
from test44.rb:10
from test44.rb:5:in `each'
from test44.rb:5
Clearly there's a permissioning issue here, but in NT I've given "Everyone" full control of both drives.
Thanks!
Kurt Euler
Subject: Re: 2 simple file copying questions, please assist...
From: "daz" <[email protected]>
Date: Sat, 4 Oct 2003 16:33:37 +0900
References: 83616 </cgi-bin/scat.rb/ruby/ruby-talk/83616>
syscopy (in 'ftools' lib) can take a directory as its target
and copies the source files' basename.
#------------
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
Thanks for your suggestion way below. It looks very promissing, but it seems I'm having momentary permissioning problems on my NT machine. Please assist if you can. When I run this code...
require 'ftools'
TARGET = 'C:/test/rbcopies' # target directory
Dir.mkdir(TARGET) unless File.directory?(TARGET)
for f in Dir.glob("./**/*")
next unless File.file?(f)
#
# check for exists? / read-only etc.
#
File.syscopy(f, TARGET)
end
... I get this error:
test44.rb:3:in `mkdir': No such file or directory - C:/test/rbcopies (Errno::ENOENT)
from test44.rb:3
When I change the drive letter in TARGET (line 2) from C: to D:, I get this error:
c:/ruby/lib/ruby/1.8/ftools.rb:23:in `initialize': Permission denied - D:/test/rbcopies/PJF_AppCenter_FnS.doc (Errno::EACCES)
from c:/ruby/lib/ruby/1.8/ftools.rb:23:in `open'
from c:/ruby/lib/ruby/1.8/ftools.rb:23:in `syscopy'
from test44.rb:10
from test44.rb:5:in `each'
from test44.rb:5
Clearly there's a permissioning issue here, but in NT I've given "Everyone" full control of both drives.
Thanks!
Kurt Euler
Subject: Re: 2 simple file copying questions, please assist...
From: "daz" <[email protected]>
Date: Sat, 4 Oct 2003 16:33:37 +0900
References: 83616 </cgi-bin/scat.rb/ruby/ruby-talk/83616>
Kurt Euler said: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
syscopy (in 'ftools' lib) can take a directory as its target
and copies the source files' basename.
#------------
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