• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 827
  • Last Modified:

How can I concatenate date /t, time /t, and an argument in a batch file and append that as one line to a file?

In Windows,

I want a batch file that will append a file with one line that has the date and time on the line, followed by some test, but I want it all on one line.  I pass in an argument that contains the text.

This is what I have now:

rem - Batch file to add a line of text to a daily notes file
date /t >> C:\dailynotes.txt
time /t >> C:\dailynotes.txt
rem - The text is argument 2
echo %1 >> C:\dailynotes.txt


This is the way it looks in my file:
03/11/2011
10:55 AM
TRYTHIS 03/11/2011
11:02 AM
stuff

How can I get those three items onto one line in the file, not three?
0
cashonly
Asked:
cashonly
  • 3
  • 2
2 Solutions
 
knightEknightCommented:
echo %date% %time% >> C:\dailynotes.txt
0
 
Christopher McKayCommented:
Have you considered trying something like this:

echo %date%, %time% "stuff" >>c:\dailynotes.txt

Hope this helps!

:o)

Bartender_1
0
 
knightEknightCommented:
The following is basically the same thing, but it eliminates the Day-of-Week from the date and the milliseconds from the time:

echo %date:~4% %time:~0,8% >> C:\dailynotes.txt
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Christopher McKayCommented:
Apparently I type too slow, sorry for duplicating you knightEknight.
0
 
cashonlyAuthor Commented:
I'm splitting the points cause while knightEknight was quicker, Bartender_1 was more complete.

TYVM to both!
0
 
knightEknightCommented:
no worries BT!  Great minds think alike...  and so do ours.  :p
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now