You should be able to use:
        File.rename("afile", "afile.bak")

This is listed in the Pragmatic Programmer's (free) Guide to Ruby:
http://www.rubycentral.com/book/ref_c_file.html

So you'd just do a little:

if File.exists?("test.xls")
        File.rename("test.xls", "old_test.xls")
else...
end...

Thanks,
Adam


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of vijay
Sent: Wednesday, June 06, 2007 12:15 PM
To: [email protected]
Subject: [Wtr-general] Can an 'excel' file be renamed with a Watir
command?

Hello people,

I have got a script that creates an 'excel_file' while running.  After
running, I want to rename it so that next time, when the script is run,
it will create the excel file anew.  Can I do that?  I tried a few DOS
commands but I could find only two DOS commands working in Watir.  They
are 'Dir.mkdir(directory)' and 'rmdir(directory)'

Thanks, in Advance,
Vijay
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to