简体   繁体   中英

How do I add the content of an environment variable to a file in windows batch?

Under windows, I would like to add the content of an environment variable, say JOB_NUMBER to a file, say C:\\job_numbers.txt .

Example: The file is empty and JOB_NUMBER contains the value 100. I want the content of the file C:\\job_numbers.txt then to be

100

When I repeat this step and JOB_NUMBER now contains the value 101, I want the content of the file C:\\job_numbers.txt then to be

100
101

(so each new addition in a new line).

How can I achieve this in windows batch without a complicated mechanism and without installing something else?

>>"C:\job_numbers.txt" echo %job_number%

Note that the quotes are only required if the filename contains spaces; they're harmless otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM