i want a new file name from existing file name but with attaching time
stamp but gives error invalid argument type please tell simple way for
doing this
···
--
Posted via http://www.ruby-forum.com/.
i want a new file name from existing file name but with attaching time
stamp but gives error invalid argument type please tell simple way for
doing this
--
Posted via http://www.ruby-forum.com/.
If you do not tell us what you did and what error you saw we cannot
help you. Did you look at
class Time - RDoc Documentation ?
Kind regards
robert
2008/5/7 Sunny Bogawat <sunny_bogawat@neovasolutions.com>:
i want a new file name from existing file name but with attaching time
stamp but gives error invalid argument type please tell simple way for
doing this
--
use.inject do |as, often| as.you_can - without end
Robert Klemme wrote:
2008/5/7 Sunny Bogawat <sunny_bogawat@neovasolutions.com>:
i want a new file name from existing file name but with attaching time
stamp but gives error invalid argument type please tell simple way for
doing thisIf you do not tell us what you did and what error you saw we cannot
help you. Did you look at
class Time - RDoc Documentation ?Kind regards
robert
i want attaches a timestamps to file for this i doing Time.now_filename
but it gives error because time has a space sum it so i need some
another mechanism using which i generate timestamps and attached to
timestamps.
--
Posted via http://www.ruby-forum.com/\.
# i want attaches a timestamps to file for this i doing
# Time.now_filename
# but it gives error because time has a space sum it so i need some
# another mechanism using which i generate timestamps and attached to
# timestamps.
pardon me if i do not get you right here, but do you want something like this, eg?
system "dir *testing.rb"
01/31/2003 05:55 PM 4 testing.rb
1 File(s) 4 bytes
#=> true
require 'fileutils'
#=> true
FileUtils.mv f, [Time.now.strftime("%Y-%m-%d-%H%M%S"),f].join("_")
#=> 0
system "dir *testing.rb"
01/31/2003 05:55 PM 4 2008-05-07-173139_testing.rb
1 File(s) 4 bytes
#=> true
kind regards,
-botp
From: Sunny Bogawat [mailto:sunny_bogawat@neovasolutions.com]
Not sure what you are really doing, I get
$ ruby -e 'Time.now_filename'
-e:1: undefined method `now_filename' for Time:Class (NoMethodError)
But Pena's solution is probably what you want. Here's another approach:
file_name = "base_name-#{Time.now.strftime('%Y%m%d-%H%M%S')}"
Kind regards
robert
On 07.05.2008 11:08, Sunny Bogawat wrote:
Robert Klemme wrote:
2008/5/7 Sunny Bogawat <sunny_bogawat@neovasolutions.com>:
i want a new file name from existing file name but with attaching time
stamp but gives error invalid argument type please tell simple way for
doing thisIf you do not tell us what you did and what error you saw we cannot
help you. Did you look at
class Time - RDoc Documentation ?i want attaches a timestamps to file for this i doing Time.now_filename but it gives error because time has a space sum it so i need some another mechanism using which i generate timestamps and attached to timestamps.