From: Hawksury Gear Date: 2010-04-08T21:16:28+09:00 Subject: Re: Copying all Files with New Name Thanks very much , all worked very well. I can now, - Copy all files from a directory with a new name to the required destination. I would appreciate if you can give some suggestions regarding the following, Problem: Defining a specific File Size when copying over, say of size= 2MB For example if source file size is = 20MB, I want to get total of 10 files of size 2MB. Something like, # when copying if file.size > 2MB "Stop" AND # Create a new file again when copying if file.size > 2MB "Stop" # Create a new file # And so on... Probably,dividing the file size by 2 and then creating that many files to copy the contents over so if file.size = 20 total files = 20/2 Also the most difficult thing for me is how to keep track of what data has been copied over already ? Something like, # Create a new file if size > 2MB # AND Copy the data from the point onwards. I hope that I have explained well what I actually want to achieve. Any suggestions would be much appreciated including any methods in ruby any common tricks for doing the above? The Current Code i am using isn't intelligent it copies over an entire file regardless of the file size, Works perfectly fine, def unique_filename(location, basename = '', extension = '.txt', digits = 4) # Initializing file extension extension = extension ? ".#{extension}" : '' index = 0 namer = lambda { "#{basename}#{index.to_s.rjust(digits,'0')}#{extension}" } name = namer.call while File.exists?(File.join(location, name)) index = index + 1 name = namer.call end File.join(location, name) end Many Thanks, Gear -- Posted via http://www.ruby-forum.com/.