Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
44 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 43

Caras, more...
Support us!
Recent OS4 Files
OS4Depot.net





Add date+time to filename
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 140
Is there a way to add the date+time to a filename when redirecting output? This is to be done in a Shell directly or a script.

MyProgram >T:Output_[date+time].txt

So each run doesn't overwrite the previous output file.

   Report Go to top

Re: Add date+time to filename
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1069
What I usually do is set up a Shell variable with the date part of the filename, using something like "set dt = `date {your format codes here]`" (note the backticks).

Then you can use $dt as part of your filename - or, if you refer to it lots of times, set up another variable like "set fn = T:Output_$dt.txt" and then just use $fn when you need the filename.

Note: Untested, away from my Amigas right now.

Best regards,

Niels


   Report Go to top

Re: Add date+time to filename
Just can't stay away
Joined:
2008/1/6 17:56
From Pennsylvania, USA
Posts: 1291
@mritter0
Maybe some variation of this:

echo testing >ram:testfile`date LFORMAT %H%M%S`

Note that the hash marks enclosing the date command are not single quotes; they are the character below the Esc key on a standard keyboard (I.E. the key with ~ and `).

_________________
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

   Report Go to top

Re: Add date+time to filename
Not too shy to talk
Joined:
2006/12/6 19:36
Posts: 446
@mritter0

if it's not strictly the date you are after but the overwriting of the previous file from a script, maybe adding the process number to the file name is an option?

.Key test
.Bra {
.
Ket }

echo 
"hello Amigans World" >T:nameoffile{$$}



   Report Go to top

Re: Add date+time to filename
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 140
Sweet. Worked great. Thanks

_________________
Workbench Explorer - A better way to browse drawers
   Report Go to top

Re: Add date+time to filename
Just popping in
Joined:
2012/2/15 11:05
Posts: 91
@mritter0

In case you need a single file containing the cumulative output data of previous execution/run , you may use: MyProgram >>T:Output.txt

   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project