Solved

saving string value to a file

Posted on 2014-09-04
2
145 Views
Last Modified: 2014-09-04
I want to save string variable from .cmd to external file. Just to append it not overwrite it. Something like this

current date/time     string value

Is it possible?
0
Comment
Question by:axcx
2 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 250 total points
ID: 40303316
Just use the "double" redirection, which will append instead of overwrite: ">>". You can add it before or after the echo ..." command, but I prefer it in front so there are no trailing spaces or the need for brackets:
>>"C:\Temp\echo_date.txt" echo current date/time: %Date% %Time%

Open in new window

or (with a trailing space at the end of the line):
echo current date/time: %Date% %Time% >>"C:\Temp\echo_date.txt"

Open in new window

or (no trailing space, but with brackets)
(echo current date/time: %Date% %Time%)>>"C:\Temp\echo_date.txt"

Open in new window

0
 
LVL 9

Assisted Solution

by:dlb6597
dlb6597 earned 250 total points
ID: 40303321
echo %time% %string% >>output.txt

where %string% is your variable, output.txt is the file you wish to append to.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now