Hi,
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,
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 ?
Any suggestions about giving random names for the new files..?
Many Thanks,