Batch file that can discriminate all text except few words

January 24, 2019 at 19:02:41
Specs: Windows 10
I need help with my Batch script, i want to extract some text i don´t have, which is from a comparison from the output of a command, in the example I want to extract: OtherWifi and OtherWifi2. Ignore everything, and yes it is in spanish. I would really apreciate some help on this matter, and as long as I can later use the words in separated commands, it will work for me.

Comparando archivos F:\PROYECTO\profiles.txt y F:\PROYECTO\COMPROBAR.TXT
***** F:\PROYECTO\profiles.txt
Perfil de todos los usuarios : MyWifi

***** F:\PROYECTO\COMPROBAR.TXT
Perfil de todos los usuarios : MyWifi
Perfil de todos los usuarios : OtherWifi
Perfil de todos los usuarios : OtherWifi2

*****

message edited by yoyojambo


See More: Batch file that can discriminate all text except few words

Reply ↓  Report •

#1
January 26, 2019 at 19:07:45
All im going to say right now, is that a script like you are suggesting is kinda time consuming to write in Batch. (mostly because i have to keep track of what i already have extracted or not)
I can still do it, but i'm not really in the mood right now, perhaps check back next week.

"I can later use the words in separated commands, it will work for me."
How do you want the the command to look like?

i5-6600K[delid]@4.7GHz/4.4GHz cache/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz


Reply ↓  Report •

#2
January 26, 2019 at 20:52:59
Thanks man, I would really apreciate your help, doesn't matter if it takes a week or a month. And the command I would use for the extracted words would be something like:

netsh wlan show profile OtherWifi key=clear

I would really apreciate any help, I'm new to scripting and this question arose basically because of my lack of knowledge and understending, so I would agree to just give out the whole script if necesary. I'm sure it's a very bad script, poorly elaborated in general, so if anybody wants it, just ask for it.
Thanks again.


Reply ↓  Report •

#3
January 26, 2019 at 22:11:38
F:\PROYECTO\profiles.txt and F:\PROYECTO\COMPROBAR.TXT
substitute "a1", "a2" respectively to save typo's and linguistic challenge.
@echo off & setlocal
for /f "tokens=1,2 delims=:" %%a in (a1) do for /f "tokens=2 delims=:" %%e in ('find "%%a"^<a2^|find /v ":%%b"') do (
echo target: %%e
echo netsh wlan show profile %%e key=clear
pause
netsh wlan show profile %%e key=clear
)

Like Hide said, what/where you want this output is up for grabs. This is just prototype to work from. Pauses for debugging purposes.

message edited by nbrane


Reply ↓  Report •

Related Solutions

#4
January 27, 2019 at 10:18:59
What are you actually trying to do? What's the actual starting point and desired outcome of this batch? There might be a better way to go about it.

How To Ask Questions The Smart Way


Reply ↓  Report •

#5
January 27, 2019 at 14:37:14
Thank you so much nbrane, but there is a problem, I changed the file names that you adviced me to, and added the script you posted, it starts, but throws an error message:

"El sistema no puede encontrar el archivo a1."
This is translated to: "The sistem can't find file a1"

I don't know what is the problem, but I must say that the script runs from a USB and all the files to run the script are also on the USB, I don't know if this is part of the problem, but it might be helpful mentioning it.

And to Razor: basically the script compares the list of internet profiles which was taken from my computer to one made on the computer where it is been ran on. If there is a profile in the computer that my list doesn't have, then it gets the password for that profile(s) and writes down both, on a separate file. Here is the script that I have done so far:( Keep in mind I am new to scripting, and basically anything there is to be about computer programs, so don't be too meticulous while judging this)

echo off
>a2.txt (
netsh wlan show profile
)

>resultado.txt (
fc F:\Proyecto\a1.txt F:\Proyecto\a2.txt
)
@echo off & setlocal
for /f "tokens=1,2 delims=:" %%a in (a1) do for /f "tokens=2 delims=:" %%e in ('find "%%a"^<a2^|find /v ":%%b"') do (
echo target: %%e
echo netsh wlan show profile %%e key=clear
pause
netsh wlan show profile %%e key=clear
)

It basically steals your wifi passwords.
I must say that I'm doing it for fun, not to actually steal people's passwords.


Reply ↓  Report •

Ask Question