Solved Windows 7 FINDSTR batch question

Radiomange

New member
Local time
11:54 PM
Messages
5
I am programming a search using some batch files and the following works correctly.

findstr /b /l "Pilot Name=" e:\dvd\test\ITrac.ini >out

It creates a file OUT that has the correct information in it, so I know the FINDSTR is working. I don't need a file, I need the output in a variable so I can strip the first 11 characters off the output and continue on. I can't seem to get that right. Anyone have suggestions?
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 10 Home 32 bit
This might work to set the output to a variable:

Code:
cmd > tmpFile  
set /p myvar= < tmpFile  
del tmpFile

I'm no big genius when it comes to batch files, but it might work. Personally, if it were me, I would do it in C#. Much finer granularity and control over the processed string.

But that's just me. :)
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Mellon Labs (custom build)
OS
Win 7 Pro x64/Win 10 Pro x64 dual boot
CPU
AMD FX 8350 Vishera @ 4200
Motherboard
ASUS M5A97 R2.0
Memory
16 GB Mushkin Blackline DDR3-2400 @ 1866 (9-10-10-10-31)
Graphics Card(s)
XFX Radeon R9 280 Double D Black Edition
Sound Card
Realtek HD Audio on MB. Sounds great.
Monitor(s) Displays
Acer 24", Acer 22"
Screen Resolution
3840 x 1080
Hard Drives
1 x Mushkin Chronos 120 GB SSD (Win 10)
1 x Samsung 850 EVO 250 GB SSD (Win 7)
1 x WD 1TB SATA Blue
1 x WD 1TB SATA Green
PSU
Corsair TX-750
Case
CoolerMaster HAF 912+
Cooling
Coolermaster Seidon 240M Liquid AIO. 6 case fans
Keyboard
Logitech G710+
Mouse
Logitech G500s
Internet Speed
Much better since I got fiber, but still way overpriced.
Antivirus
MSE, Malware Bytes for scanning
Browser
Firefox
Other Info
Corsair VOID USB headphones.

A Mellon Labs X-1 - LCD Smartie driven system status display.

Brought to you by the letter E
I was finally able to get this working using a FOR command and a FindStr together in one line of code.
Following is the working line, FYI
FOR /f "delims=;" %%A in ('findstr /b /c:"Pilot Name=" e:\G4_Mods\test\ITrac.ini') Do SET $B=%%A
Thanks
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 10 Home 32 bit
Glad you got it working. Thanks for posting your results to help the next person with this question. :)
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Mellon Labs (custom build)
OS
Win 7 Pro x64/Win 10 Pro x64 dual boot
CPU
AMD FX 8350 Vishera @ 4200
Motherboard
ASUS M5A97 R2.0
Memory
16 GB Mushkin Blackline DDR3-2400 @ 1866 (9-10-10-10-31)
Graphics Card(s)
XFX Radeon R9 280 Double D Black Edition
Sound Card
Realtek HD Audio on MB. Sounds great.
Monitor(s) Displays
Acer 24", Acer 22"
Screen Resolution
3840 x 1080
Hard Drives
1 x Mushkin Chronos 120 GB SSD (Win 10)
1 x Samsung 850 EVO 250 GB SSD (Win 7)
1 x WD 1TB SATA Blue
1 x WD 1TB SATA Green
PSU
Corsair TX-750
Case
CoolerMaster HAF 912+
Cooling
Coolermaster Seidon 240M Liquid AIO. 6 case fans
Keyboard
Logitech G710+
Mouse
Logitech G500s
Internet Speed
Much better since I got fiber, but still way overpriced.
Antivirus
MSE, Malware Bytes for scanning
Browser
Firefox
Other Info
Corsair VOID USB headphones.

A Mellon Labs X-1 - LCD Smartie driven system status display.

Brought to you by the letter E
Back
Top