From: Hawksury Gear Date: 2010-04-06T03:17:48+09:00 Subject: Copying all Files with New Name Hi, This forum has already been very helpful , Many Thanks. Problem: I actually want to copy the contents of all files that is in a particular directory into a new directory.The new files should be of a specific size (2MB)and each with a new name (randomly assigned). My Current Code looks, require 'ftools' testdir = "K:/test" # Iterating over each entry Dir.entries(testdir).each do |file| # Joining the path where the files are path = File.join testdir, file if File.file? path File.open path File.copy(file,'K:/t1') # NOTE: t1 file doesn't exist assuming will create itself? probably wrong end end end When simply trying to copy using File.copy(to,from) it gives following error message "No such file or directory K:/" Do you think this approach is completely wrong and I should try creating File.new and reading every single line and copying over? Any suggestions about giving random names for the new files..? Many Thanks, -- Posted via http://www.ruby-forum.com/.