Deleting Part of a String That Includes Spaces

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mungurk@gmail.com
Posts: 6
Joined: 26 Sep 2016 15:02

Deleting Part of a String That Includes Spaces

#1 Post by mungurk@gmail.com » 27 Sep 2016 11:57

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

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Deleting Part of a String That Includes Spaces

#2 Post by Squashman » 27 Sep 2016 12:08

Why are you not using the environmental variable %COMPUTERNAME%

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Deleting Part of a String That Includes Spaces

#3 Post by Squashman » 27 Sep 2016 12:13

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.

mungurk@gmail.com
Posts: 6
Joined: 26 Sep 2016 15:02

Re: Deleting Part of a String That Includes Spaces

#4 Post by mungurk@gmail.com » 27 Sep 2016 12:54

%computername% clearly had gone out of my head - thanks, I needed that!

Post Reply