Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-11
6
Medium Priority
?
826 Views
Last Modified: 2012-06-22
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
Comment
Question by:cashonly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 33

Assisted Solution

by:knightEknight
knightEknight earned 1000 total points
ID: 35110438
echo %date% %time% >> C:\dailynotes.txt
0
 
LVL 22

Accepted Solution

by:
Christopher McKay earned 1000 total points
ID: 35110444
Have you considered trying something like this:

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

Hope this helps!

:o)

Bartender_1
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35110471
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 22

Expert Comment

by:Christopher McKay
ID: 35110477
Apparently I type too slow, sorry for duplicating you knightEknight.
0
 

Author Closing Comment

by:cashonly
ID: 35110481
I'm splitting the points cause while knightEknight was quicker, Bartender_1 was more complete.

TYVM to both!
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35110489
no worries BT!  Great minds think alike...  and so do ours.  :p
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question