Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows 7 FINDSTR batch question

03 Mar 2017   #1
Radiomange

Windows 10 Home 32 bit
 
 
Windows 7 FINDSTR batch question

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 System SpecsSystem Spec
.
04 Mar 2017   #2
Mellon Head

Win 7 Pro x64/Win 10 Pro x64 dual boot
 
 

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 System SpecsSystem Spec
04 Mar 2017   #3
Radiomange

Windows 10 Home 32 bit
 
 

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 System SpecsSystem Spec
.

05 Mar 2017   #4
Mellon Head

Win 7 Pro x64/Win 10 Pro x64 dual boot
 
 

Glad you got it working. Thanks for posting your results to help the next person with this question.
My System SpecsSystem Spec
Reply

 Windows 7 FINDSTR batch question




Thread Tools




Similar help and support threads
Thread Forum
Batch File Question
I am incredibly ignorant about batch files, yet I'd like to create one to do weekly backups of my documents. The following .bat file more or less works, but it needs tweaking. xcopy /e /y /c /s /i c:\users\scott\documents h:\Backup The H: drive is a large external drive. The above file...
General Discussion
batch file question
I have a batch file to restart windows and want to do on a schedule. shutdown.exe /r /t 00 But when i try it manually or try to restart from start/restart there are programs running in the background and i have to force restart. What do i add to the batch file to stop the programs or force...
General Discussion
Newb, Win 7 Batch file question-KVM switching
hello Sorry if I'm posting this to the wrong place, but I'm not sure what this would be classed under. I would like to be able to change between the two computers connected to my KVM by clicking on an icon. My Belkin KVM has a remote switch that should be on my desktop, but my two cats...
General Discussion
Quick batch file question
Hi, I have just created a batch file to backup a few things on my machine, the thing is the batch file has a menu in it and i was wondering if i was to set the batch file to run under task scheduler say once a week is there a way i can get it to excute through the menu of the batch file? if not...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 23:06.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App