From: Peter Bailey Date: 2007-03-07T03:04:02+09:00 Subject: Re: Attributing an old time stamp for a new file. Rob Biedenharn wrote: > On Mar 6, 2007, at 11:43 AM, Peter Bailey wrote: >>> >>> >>> >> FileUtils.touch("file1", "file2") >> >> What does "t" stand for above? > > it is set to Time.now, but you want to do something like: > > newfile = "#{oldfile}.txt" > File.open(oldfile) do |o| > File.open(newfile, 'w') do |n| > # while line = o.gets > # n << fixup(line) > # end > end > end > t = File.mtime(oldfile) > File.utime(t,t, newfile) > > Of course the inner loop is whatever you need it to be. The key here > is to just do the part of FileUtils.touch that you need which is the > call to File.utime on the new file. Since you just had to create it > (and fill it with something), you don't have to create it (the rescue > clause in touch). > > (I hadn't run across the File.utime before, but I should've expected > that from Perl's influence.) > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com Thank you all, gentlemen. These lines are the ones that made it shine for me, Rob: t = File.mtime(oldfile) File,utime(t,t,newfile) because that's exactly what I need to do. I need to grab the time stamp for my postscript files and then assign those times to my simple text files derived from those .ps files. Thanks again! -Peter -- Posted via http://www.ruby-forum.com/.