Solved

saving string value to a file

Posted on 2014-09-04
2
151 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
[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
2 Comments
 
LVL 85

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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 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