Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6645
| From | Charles Calvert <cbciv@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: adding directory location to my file output script |
| Date | 2012-10-10 21:41 -0400 |
| Organization | NewsGuy - Unlimited Usenet $19.95 |
| Message-ID | <dg8c78ptuaph5vi86oa0itn0p5b4a35squ@4ax.com> (permalink) |
| References | <f5075c06-b7f2-4cd3-a40c-906547bdc120@googlegroups.com> |
On Wed, 10 Oct 2012 13:04:35 -0700 (PDT), crossanpdx@gmail.com wrote
in <f5075c06-b7f2-4cd3-a40c-906547bdc120@googlegroups.com>:
> Below is my script which create me a html file called pickle.html
> and then when ran again, it checks if exists and if so appends to
> the file and creates new one.
>
> I need to tell the script where I want to the html file to go to.
>
> I run this from the working directory and in the same directory is
> a folder called 'logs' so I would like all the pickle.html files
> to go to logs.
[snip]
>require 'date'
>
>file, new_file = 'pickle.html', DateTime.now.strftime('%s')
How about:
file, new_file = 'logs/pickle.html', DateTime.now.strftime('%s')
>if File.exists?('file')
Why are you enclosing file in quotation marks? That's a string
literal, not a variable name.
> File.rename('file', "pickle_#{new_file}.html")
File.rename(file, "logs/pickle_#{new_file}.html")
[snip rest]
--
Charles Calvert | Websites
Celtic Wolf, Inc. | Web Applications
http://www.celticwolf.com/ | Software
(703) 580-0210 | Databases
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar
adding directory location to my file output script crossanpdx@gmail.com - 2012-10-10 13:04 -0700
Re: adding directory location to my file output script Charles Calvert <cbciv@yahoo.com> - 2012-10-10 21:41 -0400
Re: adding directory location to my file output script Ryan Crossan <crossanpdx@gmail.com> - 2012-10-11 06:32 -0700
csiph-web