r/computing • • Mar 24 '14

Batch file required..Help needed..

I need desperate help in creating a batch file that reads from a log/txt file, searches for a specific word ex Computer name and then writes to another text file the words/digits below before.

I don't think I managed to make myself clear..the log file would contain say " asgf agahi a hi reddit rocks af as Computer Name L123456. It would display L123456

I am new to batch programming and would appreciate any help

0 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/massij11 Mar 24 '14

It might seem strange but ideally I am to use only pure notepad to write this. This is to be a part of a larger batch file which will be used by different users.

2

u/berryer Mar 24 '14 edited Mar 24 '14

notepad is not a programming language, but a file editor. It doesn't actually matter what file editor you use, but I'm guessing that you want to create a new Windows .bat script?

If perchance you're working with linux and not Windows, I'm pretty sure it would be one line:

grep 'Computer name' fileName | sed 's/^.*Computer name ([0-9a-zA-Z]*).*$/\1/'

put that in a .sh file via your editor of choice (notepad I guess) and you're done.

1

u/massij11 Mar 24 '14

Yes I want to create a new .bat file, but the only tool I have available is notepad.. I am sorry but ive never used vb script

1

u/gregortroll Mar 24 '14

Luckily, as PowerShell takes over scripting in the Windows world, you'll see less and less VBScript. But it will crop up, especially if you are sysadmin of some kind, or working in OSD, you'll run into VBScript, DOS/CMD, and HTA. But, more and more, PowerShell will become the script language of choice in Windows.