Page 1 of 1

Deleting Part of a String That Includes Spaces

Posted: 27 Sep 2016 11:57
by mungurk@gmail.com
We are trying to retrieve the computer name on a single line.
The command I am using is inserting this with preceding text on the line:
ipconfig/all | find "Host Name" >c:\whoami\whoami2.txt
produces
Host Name . . . . . . . . . . . . : MyPCName

but we are trying to have the txt file read:
MyPCName

I am getting close with FART
fart c:\whoami\whoami2.txt " Host Name . . . . . . . . . . . . : "

...but the output includes a space before the PC Name

Any advice on removing the entire string before the PC Name?

The FART app is really excellent, in case you are unfamiliar with it, available from:
http://fart-it.sourceforge.net/
and it stands for Find And Replace Text

Re: Deleting Part of a String That Includes Spaces

Posted: 27 Sep 2016 12:08
by Squashman
Why are you not using the environmental variable %COMPUTERNAME%

Re: Deleting Part of a String That Includes Spaces

Posted: 27 Sep 2016 12:13
by Squashman
mungurk@gmail.com wrote:The FART app is really excellent, in case you are unfamiliar with it, available from:
http://fart-it.sourceforge.net/
and it stands for Find And Replace Text

As you have been shown in your previous thread we already have a pretty slick find and replace app.

Re: Deleting Part of a String That Includes Spaces

Posted: 27 Sep 2016 12:54
by mungurk@gmail.com
%computername% clearly had gone out of my head - thanks, I needed that!