Solved

saving string value to a file

Posted on 2014-09-04
2
146 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

25 Experts available now in Live!

Get 1:1 Help Now