Reading a txt line by line in a batch file [closed] - batch-file

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am driving myself crasy trying to read this txt file in a batch file:
Binary CapabilityDescriptions Caption Availability
TRUE Intel(R) Active Management Technology - SOL (COM3) 2
TRUE Intel(R) Active Management Technology - SOL (COM4) 2
TRUE Intel(R) Active Management Technology - SOL (COM5) 2
I am trying to get the the COM number if the Caption contains the string "Intel".

Try this:
#echo off
setlocal
for /f "tokens=4 delims=()" %%a in ('findstr "Intel(R)" findintel.txt') do echo %%a

Related

Search for the first show of a expression in text file and copy it to the clipboard -using cmd [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I want to create a bat file that will search for a specific expression in a text file and copy it to my clipboard,
Example:
I want to search in this file C:\test.log The first instance of:
TestSerialNumber = %%%%%%%%%
(The %%%%%%%% are 8 numbers, for example: TestSerialNumber = 44436643, the numbers change)
And copy only the numbers to the clipboard
I got entangled with finding the first show.
I would appreciate help
This should work:
for /f "tokens=2 delims== " %%a in ('findstr TestSerialNumber c:\test.log') do echo %%a | clip

i am having batch file but it gives syntax error when using in windows 7 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
# echo off
move /y c:\program files (x86)\presst~1\Newsview\received\coreplus \\edt_np\pti
#echo off
d:\sleep 30
d:\wire.bat
You need to "quote parameters containing separators"
move /y "c:\program files (x86)\presst~1\Newsview\received\coreplus" \\edt_np\pti
Just had a rough look:
Seems like you need to use some " for your paths. A space leads the programm to think that the next argument start but your arguments are not c:\program and files and (x86) etc. Instead it is one string "c:\program files (x86)\presst~1\Newsview\received\coreplus"

how to remove the batch file you just used [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I remove a batch file I just used with a batch code line?
Like a code that does this:
remove thisbat.bat
Thanks in advance.
Some people will tell you to just put
DEL "%~f0"
on the last line, but that usually causes an error in that the BAT file can no longer find itself. You should use the following statement on the last line of your BAT file, because after it hits this line your BAT file is gone:
start /b "" cmd /c del "%~f0"&exit /b
This will launch a new delete process within the same console, thus eliminating any "file can no longer be found" errors.

windows scripting to search a value in '.HL7' file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Through windows batch file, I am trying to -
a. open a folder > open latest '.hl7. file (by date) in the folder.
b. search a specific value in the file. e.g value of the key 'name'
c. echo the value.
I am new to scripting, Can anybody help me write a script for the same?
I am not sure about the format of the HL7 files but this will get the most latest HL7 file into env variable MyFile and then print the lines in the file that have "name" in them.
#set MyFile=
#for /F %%I in ('dir /od /b *.hl7') do set MyFile=%%I
#if defined MyFile find "name" %MyFile%
If HL7 has many different formats you may be better off writing a program that uses an HL7 library to parse your file.
I hope this helps you get started.

Saving DOS command to a txt file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I need to save list of DOS commands itself in a text file.
But when I am using
echo copy source_file target_file >> new_command.txt
it is writing the copy command to the file correctly but at the same time it is executing the command.
What I want is that this should only write the copy command to the file without executing it..
new_command.txt should contain
echo copy source_file target_file
I don't know why you want to do this though :)
echo echo copy source_file target_file >> new_command.txt

Resources