useruseruser
useruseruser

Reputation: 71

Add hostname for each line in a text file using cmd

I am new with the batch file.

How can I append hostname in a text file

-Text file 1 -

Text Line 0
Text Line 1
Text Line 2 
.
.
. 

Expected result in Text File 2

Hostname + Text Line 0
Hostname + Text Line 1
Hostname + Text Line 2
. 
.
.

Upvotes: 0

Views: 1258

Answers (1)

Wasif
Wasif

Reputation: 15470

You can do this:

@echo off
echo %computername% + line 1 >>txtfilepath.txt
:: Continue like above, here %computername% is the host name

Upvotes: 1

Related Questions