FileUtils.cp, places extra copy when it shouldn't be guidance?

My code

#!usrbinenv ruby

require ‘fileutils’

my_dir = Dir["C:/Documents and
         Settings/dolinc2/Desktop/talfolder/*.doc"]

(“0000”…“9999”).each do |c|

my_dir.each do |filename|

begin FileUtils.cp( filename, "C:/Documents and
         Settings/dolinc2/Desktop/ccfolder/" + c + "/" +

File.basename(filename, “.doc”))

rescue

end
end
end

Ok the only thing here is that even if the file doesn’t match the
directory it still puts a copy of a blank File (with type File) in the
folder

I don’t understand why… =(

Hi,

I’m not sure what you mean by blank file. The code above should copy
every file with the extension “.doc” (even temporary files) into the
backup folders while deleting the extensions.

So, for example, if your documents are ‘a.doc’, ‘b.doc’ and ‘c.doc’, you
will end up with the files ‘a’, ‘b’ and ‘c’.

If you don’t want the extensions to be deleted, leave out the second
argument when calling File.basename.

Jacques